Forum Discussion

ruxandraalina's avatar
4 years ago
Solved

Power BI SWITCH

Hello, 

 

I have a turnover table where I calculate numerous turnover-related metrics inside a single measure using the switch() formula:

 

All Metrics =
var category = FIRSTNONBLANK('0_Categories'[Category], 1)
var metric = SWITCH(category,
"% Turnover", [% Turnover],
"% Turnover Voluntary", [% Turnover Voluntary],
"% Turnover Involuntary", [% Turnover Involuntary],
"% Turnover Other", [% Turnover Other])
return metric
 
The reason I am using the switch formula is because I wanted to create a matrix where all these metrics are on a row level (+months on the column level). 
 
For further analysis, I also need to calculate turnover (=the All metrics measure) by country, language, etc.
 
Instead of creating 10 different matrixes (one for each field), I am wondering if I can use the switch function (or anything else) to create a slicer for these categories. Basically, if the user selects country, then he gets a matrix with turnover by country and by month; if the user selects language, then he gets turnover by language and by month, and so on. 
 
Can anyone help me?
Thank you!
 
 

2 Replies