Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to do a little switch statement such as
Switch([Institution] , "A", "1","B",2 ....)
but after switch statement DAX does not recognize my columns where it usually pop up with intelisene and even when I type it it cannot recognize the columns. However it only recognizes the measure that I created previously. I would like to know what I am doing wrong here. Thanks
Solved! Go to Solution.
Hi @arashaga,
You want to make such a Switch statement via a measure, right? Is [institution] a field name?
Please try this
Measure = SWITCH ( SELECTEDVALUE ( Table1[institution] ), "A", CALCULATE ( COUNT ( Table1[Column] ), FILTER ( ALL ( Table1 ), Table1[Column] = "G" ) ), "B", CALCULATE ( COUNT ( Table1[Column] ), FILTER ( ALL ( Table1 ), Table1[Column] = "K" ) ) )
Best regards,
Yuliana Gu
In your case, you are trying to create a measure with SWITCH statement and hence DAX suggests only measures.
If you create this as calculated column, you will see the option of columns as well.
Thanks
Raj
How do you use switch with calculate?
If you could post some sample data and expeced output, would be easy to suggest .
If needed , you can use the IF or SWITCH in the filter with logic.
Thanks
Raj
I would like to do the following calculation. I am trying to compare one institution with it's peer institution.
For instance compare A with G and B with K. Also,
I will most likely have some other filters in the page so I would like to igonre some of them as well.
if institution = "A"
then ignore all the filters and give me the total attendance for institution G
if institution = "B"
then ignore all the filters and give me the total attendance for institution K
I hope this would help to describe what I need to do.
Hi @arashaga,
You want to make such a Switch statement via a measure, right? Is [institution] a field name?
Please try this
Measure = SWITCH ( SELECTEDVALUE ( Table1[institution] ), "A", CALCULATE ( COUNT ( Table1[Column] ), FILTER ( ALL ( Table1 ), Table1[Column] = "G" ) ), "B", CALCULATE ( COUNT ( Table1[Column] ), FILTER ( ALL ( Table1 ), Table1[Column] = "K" ) ) )
Best regards,
Yuliana Gu
Excellent solution thank you.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
61 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |