Forum Discussion
wemsomba10
1 year agoFrequent Visitor
Hello
I m using the switch function but the totals are coming out blank or just not doing any calculations. please help. Selected In Report Switch = var Myselection = SELECTEDVALUE('Change Type'[Type...
Poojara_D12
1 year agoSuper User
Hi wemsomba10
Please try the dax code:
Selected In Report Switch =
VAR Myselection = SELECTEDVALUE('Change Type'[Type])
-- Define comparison variables
VAR selectNeg = IF([Selected In Report] < [Compared In Report], "Yes", "No")
VAR selectPos = IF([Selected In Report] > [Compared In Report], "Yes", "No")
VAR selectNo = IF([Selected In Report] = [Compared In Report], "Yes", "No")
VAR selectNew = IF(AND([Selected In Report] > 0, [Compared In Report] = 0), "Yes", "No")
VAR selectAll = IF([Selected In Report] >= 0, "Yes", "No")
-- Handle the SWITCH logic
RETURN
SWITCH(TRUE(),
Myselection = "Negative Change" && selectNeg = "Yes", [Selected In Report],
Myselection = "Positive Change" && selectPos = "Yes", [Selected In Report],
Myselection = "No Change" && selectNo = "Yes", [Selected In Report],
Myselection = "New Accnt Added" && selectNew = "Yes", [Selected In Report],
Myselection = "All" && selectAll = "Yes", [Selected In Report],
-- Handle Total (default case for totals, using ISFILTERED to check if there's context)
ISFILTERED('Change Type'[Type]), BLANK() -- Return blank for the total row if no context
)
Try this modified version of the measure and let me know if the totals issue is resolved.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" ๐
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
wemsomba10
1 year agoFrequent Visitor
Hello Poojara. this did not work. i am still getting either blank totals or the overall total. not giving totals when switching to position change, negative change, new accnt added and no change.