Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello, I'm experiencing an issue with a DAX code.
When I write the code as follows, I don't get any errors.
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.
What can I do? Thank you.
Here we are trying to create a table which gains column values based on the selection.
The table's value doesn't change but the measure does.
Here the table is created within the measure's variable and thus gets the desired value.
Proud to be a Super User!
Thank you for your response. Actually, what I want to do is as follows: Dynamically filter column names based on the value selected from a slider. I created a table to use in the slider:
Risk_Table = UNION(
ROW("Risk", "A"),
ROW("Risk", "B"),
ROW("Risk", "C"),
ROW("Risk", "D"),
ROW("Risk", "E"),
ROW("Risk", "F"),
ROW("Risk", "G") )
I added a slider based on the "Risk" column from this table. I want to search among the columns of table X for the value selected in the slider and return the values that are equal to 1. For example, if "A" is selected, it should filter as X[A] = 1, and if "E" is selected, it should select those where X[E] = 1. In other words, I want to dynamically change the column name. What can I do for this?
Use calculated Groups to do that.
Create a calculated group called "Risk CG",
Within that Group create items A, B, C and so on
and return a filter from each of the items using a specific column eg: FILTER(DB_Table, A = 1)
Then use this calculated Group column in the slicer.
FilteredTableByRiskType =
VAR SelectedRisk = SELECTEDVALUE('Risk_Table'[Risk])
RETURN
FILTER(
DB_Table,
(
SelectedRisk = "A" && DB_Table[A] = 1 ) ||
(SelectedRisk = "B" && DB_Table[B] = 1) ||
(SelectedRisk = "C" && DB_Table[C] = 1) ||
(SelectedRisk = "D" && DB_Table[D] = 1)
)
)
I edited the code in the same way. But it still returned empty table.
This code return empty table:
FilteredTableByRiskType =
VAR SelectedRisk = SELECTEDVALUE('Risk_Table'[Risk])
RETURN
FILTER(
DB_Table,
(
SelectedRisk = "A" && DB_Table[A] = 1 ) ||
(SelectedRisk = "B" && DB_Table[B] = 1) ||
(SelectedRisk = "C" && DB_Table[C] = 1) ||
(SelectedRisk = "D" && DB_Table[D] = 1)
)
)
But this code return correct data:
FilteredTableByRiskType =
VAR SelectedRisk = SELECTEDVALUE('Risk_Table'[Risk])
RETURN
FILTER(
DB_Table,
(
SelectedRisk = "A" && DB_Table[A] = 1 ) ||
(SelectedRisk = "B" && DB_Table[B] = 1) ||
(SelectedRisk = "C" && DB_Table[C] = 1) ||
(SelectedRisk = "D" && DB_Table[D] = 1)
)
)
User | Count |
---|---|
13 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |