Search code examples
sqlsql-serverreporting-servicesoledbpowerquery

Surround Number to interpret as Text


I have a CSV files and one of the fields named period stores number. Now within SSRS, I need to make use of a multi-value parameter, due to the workings of SSRS to use this with a CSV I need to do Join(Parameters!Period.Value, ",").

This issue with this is then my data set has the following query:

="SELECT WarehouseZone, RevenueStream,ClientID,CONVERT(varchar(10),Period) FROM BudgetCSV.csv 
WHERE WarehouseZone IN ('" & Join(Parameters!Warehouse.Value,"', '") & "') 
AND (RevenueStream IN ('" & Join(Parameters!AnalysisCode.Value,"', '") & "'))
AND (ClientID IN ('" & Join(Parameters!Customer.Value,"', '") & "'))
AND (CONVERT(varchar(10),Period) IN  ('"& Join(Parameters!Period.Value, "','") & "'))"

This code works fine for the zone, stream and client, I get a data type mismatch of period.

Is there any way using Powerquery to have the csv think that period is text. I have seen somewhere that by making the column say ="1" it would interpret that as text instead of an integer.


Solution

  • EDIT: THE FOLLOWING DOES NOT WORK - Using this method only works on an individual level, luckily there is a better solution

    So I mentioned in an earlier post that I could get around using the Join by creating a single parameter for each period, but this was causing an issue where if I selected 10, 1 would also be return because, strings.

    This was due to me using the following code on each of these parameters

    =iif(Join(Parameters!Period.Value,",").ToLowerInvariant().Contains("10"), "10",-999)
    

    Simple changing that code to the following

    =iif(Join(Parameters!Period.Value,",") = 1, 1,-999)
    

    So the issue is solved, but any input on how I could get a more dynamic solution working would be great as there may be times in the future when I need to use a longer list of numbers.