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...
Sahir_Maharaj
1 year agoSuper User
Hello wemsomba10,
Can you please try this approach:
Selected In Report Switch =
VAR Myselection = SELECTEDVALUE('Change Type'[Type], "All")
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])
)
VAR SelectedInReport =
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
)
)
)
VAR selectNeg = IF(SelectedInReport < [Compared In Report], "Yes", "No")
VAR selectPos = IF(SelectedInReport > [Compared In Report], "Yes", "No")
VAR selectNo = IF(SelectedInReport = [Compared In Report], "Yes", "No")
VAR selectNew = IF(AND(SelectedInReport > 0, [Compared In Report] = 0), "Yes", "No")
VAR selectAll = IF(SelectedInReport >= 0, "Yes", "No")
VAR Result =
SWITCH(
TRUE(),
Myselection = "Negative Change" && selectNeg = "Yes", SelectedInReport,
Myselection = "Positive Change" && selectPos = "Yes", SelectedInReport,
Myselection = "No Change" && selectNo = "Yes", SelectedInReport,
Myselection = "New Accnt Added" && selectNew = "Yes", SelectedInReport,
Myselection = "All" && selectAll = "Yes", SelectedInReport,
BLANK()
)
RETURN
IF(
ISINSCOPE('Change Type'[Type]),
Result,
SUMX(
VALUES('Change Type'[Type]),
SWITCH(
TRUE(),
Myselection = "Negative Change", IF(selectNeg = "Yes", SelectedInReport, BLANK()),
Myselection = "Positive Change", IF(selectPos = "Yes", SelectedInReport, BLANK()),
Myselection = "No Change", IF(selectNo = "Yes", SelectedInReport, BLANK()),
Myselection = "New Accnt Added", IF(selectNew = "Yes", SelectedInReport, BLANK()),
Myselection = "All", IF(selectAll = "Yes", SelectedInReport, BLANK()),
BLANK()
)
)
)
wemsomba10
1 year agoFrequent Visitor
thank you but the totals are still blank