Power BI Measures in slicer
This article is originally published at https://tomaztsql.wordpress.com
Power BI measures are mainly used to show and visualize data, that can be measured. But from time to time, end-users will want to have measures to be easily selected and graphs or tables changed, in accordance with selection. And I have seen this example numerous time.
For example, let’s suppose we have a sample data:
In this sample, we clearly see, that sales columns are expressed in different currencies. And end-users, for this particular case, would want to have the currency easily select-able and all the underlying graphs or tables, changed accordingly. In a way, we would want to have data transposed in order to for the columns to be selected through slicer and not through filters in Power BI.
Let’s get the data from Github and import the file “SalesData.csv” into new Power Bi document. Next step, we will need to convert the integer columns (columns in essence that we want to use in slicer) to measures.
SalesCHF_Sum = SUM(SalesData[SalesCHF]) SalesEUR_Sum = SUM(SalesData[SalesEUR]) SalesUSD_Sum = SUM(SalesData[SalesUSD])
SelectedCurrencyMeasure = VAR MyCurrency = SELECTEDVALUE ('MeasuresTable'[Measure]; "SalesCHF_Sum") RETURN SWITCH ( TRUE (); SelectedCurrencyMeasure = "SalesCHF_Sum"; [SalesCHF_Sum]; SelectedCurrencyMeasure = "SalesEUR_Sum"; [SalesEUR_Sum]; SelectedCurrencyMeasure = "SalesUSD_Sum"; [SalesUSD_Sum]; [SalesCHF_Sum] )
The only thing left is now to create a Visual and Slicer using this SelectedCurrencyMeasure measure in order to get the full effect:
The Dataset and PBIX file is available in Github and is available for you to play with it.
Happy Power BIng!
Thanks for visiting r-craft.org
This article is originally published at https://tomaztsql.wordpress.com
Please visit source website for post related comments.