I'm experiencing an issue with a DAX code.
When I write the code as follows, I don't get any errors.
FilteredTableByRiskType =
**VAR SelectedRisk = "A"**
VAR FilteredTable =
FILTER(DB_Table,
SWITCH(SelectedRisk ,
"A", DB_Table[A]=1 ,
"B", DB_Table[B] =1,
"C", DB_Table[C]=1 ,
"D", DB_Table[D] =1,
FALSE()
)
)
RETURN
FilteredTable
However, if I write it like this, it returns an empty table. I'm also checking the SelectedRisk value in a table, and I'm able to retrieve it correctly.
FilteredTableByRiskType =
**VAR SelectedRisk = SELECTEDVALUE('Risk_Table'[Risk])**
VAR FilteredTable =
FILTER(DB_Table,
SWITCH(SelectedRisk ,
"A", DB_Table[A]=1 ,
"B", DB_Table[B] =1,
"C", DB_Table[C]=1 ,
"D", DB_Table[D] =1,
FALSE()
)
)
RETURN
FilteredTable
I also tried the following code for checking, and it returns "True."
IsTest = SELECTEDVALUE(Risk_Table[Risk]) = "A"
What can I do? Thank you.
I tried different methots.
Perhaps you are needing a Measure, try:
This measure will return the number of rows matching your criteria, add this measure to your visual and/or add it to the visual filter pane.