Forum Discussion
Dax based on slicer selection
Trying to create a dax based on the slicer selection of properties.
I had to create a measure to find the variance between two tables. I will call it Net Sales Var.
So then I have a Net Sales measure. If Property A is selected in the slicer, then I need Net Sales+Net Sales Var = Total Sales.
If Property B is selected, then I need Net Sales - Net Sales Var. How can I write that into the dax?
I tried using an IF dax =
IF('Prop Dim'[Property]="Property A", blah blah, but the IF doesn't except text columns. I'm thinking I need to use SELECTEDVALUE, but not sure how to write the dax. Any help is appreciated.
You need to wrap the text column in an aggregation, such as MAX(Table[Property]) or SELECTEDVALUE (Table[Property])
Both will return the same result.
4 Replies
- PaulDBrown
Community Champion
You need to wrap the text column in an aggregation, such as MAX(Table[Property]) or SELECTEDVALUE (Table[Property])
Both will return the same result.
- Tihannah
Resolver II
That did it. Thank you!
- ryan_mayu
Super User
could you pls provide the sample data and expected output?
- Tihannah
Resolver II
I don't have an easy sample to provide. The current dax I'm trying to use says
IF('Table'[Property]="Property B", 'Table'[Sales]-Sales Var, 'Table'[Sales]+Sales Var
But because these columns are text, the IF function isn't recognizing them, so I'm not sure how to write the dax.