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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Measure with three outcomes with slicer

Hi, I have the following table:

Kiisj_0-1646390603245.png


I need help with a DAX function that combines Paid, Free and Total (Paid+Free).
So when I put in Quantity in a matrix visual I can be able to use a slicer to pick between paid, free and total.
Is this possible to do?
Appriciate any help!

3 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @Anonymous 
Yes can be done.
You create a separate table for the required selections
1.png
The create a relationship
2.png
Then create your measure

QTY = 
if ( 
    SELECTEDVALUE ( Selection[Selection] ) = "Total",
    CALCULATE ( SUM ( Data[Quantity] ), REMOVEFILTERS ( Selection ) ),
    SUM ( Data[Quantity] )
)


3.png

View solution in original post

OwenAuger
Super User
Super User

Hi @Anonymous 

I would normally solve this sort of thing with the data model rather than DAX, in this case by creating an additional table looking like this (let's call it Ticket type filter😞

Ticket type filter Ticket type
Paid Paid
Free Free
Total Paid
Total Free

 

This table could be related directly to your original table with a many:many relationship between the two Ticket type columns, but I would prefer to have a Ticket type dimension bridging the two. Note the bidirectional relationship between Ticket type filter and Ticket type:

OwenAuger_0-1646394255486.png

Filters can then be applied to 'Ticket type filter'[Ticket type filter], and the advantage is that this will work for any measure based on the Tickets fact table.

 

Simple PBIX attached.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

@Anonymous 
No issues. Of course there would be no relationship. You can then use the following code

QTY = 
SWITCH (
    TRUE, 
    SELECTEDVALUE ( Selection[Selection] ) = "Free", SUM ( Data[Quantity] ) * 0.1,
    SELECTEDVALUE ( Selection[Selection] ) = "Paid", SUM ( Data[Quantity] ) * 0.9,
    SUM ( Data[Quantity] )
)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@OwenAuger thank you! Seems to work great.

I discovered another problem regaring this issue:
I have an external source file (from excel) for competitors where I dont have the "ticket type"-column with Free and Paid. I only have the Total. 
I have to make an estimate, so lets say that 1% of the total tickets for each day are free, how can I include this in the logic that you guys helped me with?

@Anonymous 
No issues. Of course there would be no relationship. You can then use the following code

QTY = 
SWITCH (
    TRUE, 
    SELECTEDVALUE ( Selection[Selection] ) = "Free", SUM ( Data[Quantity] ) * 0.1,
    SELECTEDVALUE ( Selection[Selection] ) = "Paid", SUM ( Data[Quantity] ) * 0.9,
    SUM ( Data[Quantity] )
)
Anonymous
Not applicable

@tamerj1 That works perfect, thanks!

OwenAuger
Super User
Super User

Hi @Anonymous 

I would normally solve this sort of thing with the data model rather than DAX, in this case by creating an additional table looking like this (let's call it Ticket type filter😞

Ticket type filter Ticket type
Paid Paid
Free Free
Total Paid
Total Free

 

This table could be related directly to your original table with a many:many relationship between the two Ticket type columns, but I would prefer to have a Ticket type dimension bridging the two. Note the bidirectional relationship between Ticket type filter and Ticket type:

OwenAuger_0-1646394255486.png

Filters can then be applied to 'Ticket type filter'[Ticket type filter], and the advantage is that this will work for any measure based on the Tickets fact table.

 

Simple PBIX attached.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
tamerj1
Super User
Super User

Hi @Anonymous 
Yes can be done.
You create a separate table for the required selections
1.png
The create a relationship
2.png
Then create your measure

QTY = 
if ( 
    SELECTEDVALUE ( Selection[Selection] ) = "Total",
    CALCULATE ( SUM ( Data[Quantity] ), REMOVEFILTERS ( Selection ) ),
    SUM ( Data[Quantity] )
)


3.png

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.