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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Twitter
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
Twitter
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.