Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi Everyone,
I'm new to DAX but have been writing SQL for years. I'm struggling to find a way to include a switch statement inside of a summarise columns statement. I basically want to calculate a category on the fly like this...
EVALUATE
SUMMARIZECOLUMNS(
PRODUCT[PROCUCT CODE],
PRODUCT[PRODUCT NAME],
"Product Category", SWITCH(PRODUCT[PROCUCT CODE], "00001", "Category 1", "00002", "Category 2", "Otherwise Unknown")
)
I can put a calculated column in the tabular data model i'm using but that seems like overkill because I just need it for this one report i'm working on. In SQL, i'd have just used a case statement and that would have been the end of it 🙂
Does anyone have any advice?
Many Thanks, Stu
Solved! Go to Solution.
Hi,
Include MAX, MIN or SELECTEDVALUE to your SWITCH and you should be good to go. Example:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
Hi,
Include MAX, MIN or SELECTEDVALUE to your SWITCH and you should be good to go. Example:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
21 | |
15 | |
15 | |
11 | |
7 |
User | Count |
---|---|
25 | |
24 | |
12 | |
12 | |
11 |