Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tihannah
Resolver I
Resolver I

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.

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
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.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
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.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






That did it. Thank you!

ryan_mayu
Super User
Super User

@Tihannah 

could you pls provide the sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.