Forum Discussion
Odilon
8 years agoFrequent Visitor
SWITCH or CASE in Query for data
I would like the query for the data in my visualization to filter for different values in a field depending on the case specified in a parameter. What is the correct syntax? Something like: l...
v-jiascu-msft
8 years agoMicrosoft Employee
Hi Odilon,
Usually, we will do this with DAX rather than Power Query. In other words, we retrieve data from database and model it locally. The DAX formula could be like below.
Measure =
SWITCH (
MIN ( 'table'[REGION] ),
"PA", CALCULATE (
SUM ( Sales[Quantity] ),
'dbo_vw_WeatherData'[WeatherStationCd] IN { "AOH", "ATL" }
),
"NY", CALCULATE (
SUM ( Sales[Quantity] ),
'dbo_vw_WeatherData'[WeatherStationCd] IN { "ALB", "BGM" }
)
)
Best Regards,
Dale
Odilon
8 years agoFrequent Visitor
Great! Thank you.
How do I specify REGION as a parameter the user "checks" to specify the Weather stations to which the visualizations are applied across the pages of the report?