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...
Anonymous
1 year agoNot applicable
Hi wemsomba10 ,
I create a table as your DAX codes mentioned.
I think the reason for not displaying the results is the string of DAX code 'var Myselection = SELECTEDVALUE('Change Type'[Type])'. If when I use other functions I am able to display the results.
Selected In Report Switch =
VAR _Myselection =
MAX('Change Type'[Type] )
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" )
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]
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
wemsomba10
1 year agoFrequent Visitor
Hello,
This works but I am sorry. I forgot to mention this. the returned data " Selected In Report Switch" is also a switch function itsefl. here is the function for it. can you help please.
Selected In Report = IF(ISBLANK(
VAR Mth =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Month Select Name]=SELECTEDVALUE('Selected Time Period'[Month Year]))
VAR Qtr =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Quarter Select Name]=SELECTEDVALUE('Selected Time Period'[Quarter Year]))
VAR Yr =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Year]=SELECTEDVALUE('Selected Time Period'[Report Year]))
RETURN
IF(ISFILTERED('Selected Time Period'[Month Year]),Mth,
IF(ISFILTERED('Selected Time Period'[Quarter Year]),Qtr,
IF(ISFILTERED('Selected Time Period'[Report Year]),Yr))
)),0,
--else
VAR Mth =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Month Select Name]=SELECTEDVALUE('Selected Time Period'[Month Year]))
VAR Qtr =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Quarter Select Name]=SELECTEDVALUE('Selected Time Period'[Quarter Year]))
VAR Yr =
CALCULATE (
sum(lowes_spend_data[In Report]),lowes_spend_data[Report Year]=SELECTEDVALUE('Selected Time Period'[Report Year]))
RETURN
IF(ISFILTERED('Selected Time Period'[Month Year]),Mth,
IF(ISFILTERED('Selected Time Period'[Quarter Year]),Qtr,
IF(ISFILTERED('Selected Time Period'[Report Year]),Yr))
))