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
carlenb
Advocate II
Advocate II

Why doesn't ALLSELECTED work? Slicer issue

Hi,

 

I have the following ProductTable with the column Status: 

 

Status
Done
Ongoing
Ongoing
Done
Ongoing
Done
Done
Done
Delayed
Delayed

 

I'm trying to create a card visualiation for each status (Done, Ongoing, Delayed) to show % of total. I have created three measures, this one is for Done (the others is simply a copy paste using Ongoing and Delayed instead):

 

Var_DonePercentage =
DIVIDE(
    CALCULATE(
        COUNTROWS(ProductTable),
        ProductTable[Status] = "Done"
    ),
    CALCULATE(
        COUNTROWS(ProductTable),
        ALLSELECTED(ProductTable[Status])
    ))
 
This works as long as I don't filter anything, see below.
carlenb_0-1710765752580.png

 

However when I select for example "Done" in the slicer, the others should be 0% to avoid confusion. How can I make this happen? 

carlenb_1-1710765842429.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@carlenb Was getting weird results with CALCULATE but this No CALCULATE approach works just fine. 

Var_DonePercentage 1 = 
DIVIDE(
    COUNTROWS(
        FILTER('ProductTable', [Status] = "Done")
    ),
    COUNTROWS(ProductTable)
) + 0

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
MichaelaMul
Helper I
Helper I

Hi everyone! I am having a similar issue. I made the following measures to get the volume share of each category in a specific brand in my dataset. The two top measures are working properly, with the category measure filtering properly when selected. However, when I combine the two measures to divide it the ALLSELECTED measure stops working. What am I doing wrong?

 

 

 

Total for Category = 
CALCULATE (SUM('DATA'[Volume]), 'DATA'[Brand] = "ABC", ALLSELECTED('CategoryTable'[Category]))

Total for Brand = 
CALCULATE (SUM('DATA'[CY Reforecast]), 'DATA'[Brand] = "ABC")

Total for Category divided by Total for Brand =
DIVIDE([Total for Category], [Total for Brand])

Thanks!

 

Greg_Deckler
Super User
Super User

@carlenb Was getting weird results with CALCULATE but this No CALCULATE approach works just fine. 

Var_DonePercentage 1 = 
DIVIDE(
    COUNTROWS(
        FILTER('ProductTable', [Status] = "Done")
    ),
    COUNTROWS(ProductTable)
) + 0

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler genius! Thanks Greg, got it to work. This week suddently looks brighter 🙂 

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.