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
MichaelaMul
Helper III
Helper III

Using ALLSELECTED in Divide function

Hi everyone! 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'[Volume]), 'DATA'[Brand] = "ABC")

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

Thanks!

1 ACCEPTED SOLUTION

Still no coding required.

 

lbendlin_0-1712006423984.png

 

 

View solution in original post

12 REPLIES 12
Anonymous
Not applicable

Hi @MichaelaMul ,

 

Thanks for the reply from lbendlin .

 

I do not really know what kind of desired effect you want.

 

What do SUM('DATA'[CY Reforecast] and SUM('DATA'[Volume]) mean respectively? Why do you divide them?

 

I would appreciate it if you could provide me with sample data and a diagram of the desired effect, please remove any sensitive data in advance.

 

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi thanks for the reply! I made a typo and updated the formulas above. Here's the sample data.

 

CategoryTable:

Product GroupCategory
LIGHT SOUR CREAMSOUR CREAM
SOUR CREAMSOUR CREAM
SKIM MILKMILK
WHOLE MILKMILK
1% MILKMILK
2% MILKMILK
ORANGE JUICE DRINKS
CREAMER CREAMER
NON-DAIRY CREAMER CREAMER
LIGHT CREAMCREAMER
SPRING WATER DRINKS

 

DATA table:

StoreBrandProduct GroupTime PeriodVolume
STORE AABCLIGHT SOUR CREAMMarch12,525
STORE AABCLIGHT SOUR CREAMFebruary11,340
STORE AABCLIGHT SOUR CREAMJanuary9,720
STORE AABCSOUR CREAMMarch42,134
STORE AABCSOUR CREAMFebruary35,280
STORE AABCSOUR CREAMJanuary26,880
STORE AABCSKIM MILKMarch1,645
STORE AABCSKIM MILKFebruary1,476
STORE AABCSKIM MILKJanuary1,684
STORE AABCSKIM MILKMarch5,300
STORE AABCWHOLE MILKFebruary5,157
STORE AABCWHOLE MILKJanuary5,711
STORE AABCWHOLE MILKMarch7,900
STORE AABCWHOLE MILKFebruary7,408
STORE AABCWHOLE MILKJanuary8,632
STORE AABCWHOLE MILKFebruary3
STORE AABCSKIM MILKJanuary4
STORE AABCSKIM MILKMarch711
STORE AABCSKIM MILKFebruary667
STORE AABCSKIM MILKJanuary712
STORE AABCORANGE JUICE March65
STORE AABCORANGE JUICE February59
STORE AABCORANGE JUICE January95
STORE AABCORANGE JUICE March154
STORE AABC2% MILKFebruary136
STORE AABC2% MILKJanuary148
STORE AABC2% MILKMarch228
STORE AABC2% MILKFebruary212
STORE AABC2% MILKJanuary226
STORE AABCCREAMER March87
STORE AABCCREAMER February105
STORE AABCCREAMER January102
STORE AABCNON-DAIRY CREAMER March8,237
STORE AABCNON-DAIRY CREAMER February7,440
STORE AABCNON-DAIRY CREAMER January3,360

 

Thanks!

Like this?

 

lbendlin_0-1712002846430.png

 

Yes! The sample data doesn't show it but there are other brands and stores in the table, so I can't just total the column.

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

StoreBrandProduct GroupTime PeriodVolume
STORE AABCLIGHT SOUR CREAMMarch12,525
STORE AABCLIGHT SOUR CREAMFebruary11,340
STORE AABCLIGHT SOUR CREAMJanuary9,720
STORE AABCSOUR CREAMMarch42,134
STORE AABCSOUR CREAMFebruary35,280
STORE AABCSOUR CREAMJanuary26,880
STORE AABCSKIM MILKMarch1,645
STORE AABCSKIM MILKFebruary1,476
STORE AABCSKIM MILKJanuary1,684
STORE AABCSKIM MILKMarch5,300
STORE AABCWHOLE MILKFebruary5,157
STORE AABCWHOLE MILKJanuary5,711
STORE AABCWHOLE MILKMarch7,900
STORE AABCWHOLE MILKFebruary7,408
STORE AABCWHOLE MILKJanuary8,632
STORE AABCWHOLE MILKFebruary3
STORE BABCSKIM MILKJanuary4
STORE BABCSKIM MILKMarch711
STORE BABCSKIM MILKFebruary667
STORE BABCSKIM MILKJanuary712
STORE BABCORANGE JUICE March65
STORE BABCORANGE JUICE February59
STORE BABCORANGE JUICE January95
STORE BABCORANGE JUICE March154
STORE BABC2% MILKFebruary136
STORE BABC2% MILKJanuary148
STORE BABC2% MILKMarch228
STORE BABC2% MILKFebruary212
STORE BABC2% MILKJanuary226
STORE BABCCREAMER March87
STORE BABCCREAMER February105
STORE BABCCREAMER January102
STORE BABCNON-DAIRY CREAMER March8,237
STORE BABCNON-DAIRY CREAMER February7,440
STORE BABCNON-DAIRY CREAMER January3,360
STORE ADEFLIGHT SOUR CREAMMarch12,565
STORE ADEFLIGHT SOUR CREAMFebruary5,549
STORE ADEFLIGHT SOUR CREAMJanuary556
STORE ADEFSOUR CREAMMarch466
STORE ADEFSOUR CREAMFebruary225
STORE ADEFSOUR CREAMJanuary852
STORE ADEFSKIM MILKMarch456
STORE ADEFSKIM MILKFebruary147
STORE ADEFSKIM MILKJanuary3,654
STORE ADEFSKIM MILKMarch458
STORE ADEFWHOLE MILKFebruary4,578
STORE ADEFWHOLE MILKJanuary158
STORE ADEFWHOLE MILKMarch5,578
STORE ADEFWHOLE MILKFebruary23
STORE ADEFWHOLE MILKJanuary258
STORE ADEFWHOLE MILKFebruary78
STORE BDEFSKIM MILKJanuary954
STORE BDEFSKIM MILKMarch146
STORE BDEFSKIM MILKFebruary357
STORE BDEFSKIM MILKJanuary22
STORE BDEFORANGE JUICE March5
STORE BDEFORANGE JUICE February142
STORE BDEFORANGE JUICE January35
STORE BDEFORANGE JUICE March25
STORE BDEF2% MILKFebruary41
STORE BDEF2% MILKJanuary29
STORE BDEF2% MILKMarch596
STORE BDEF2% MILKFebruary256
STORE BDEF2% MILKJanuary45
STORE BDEFCREAMER March78
STORE BDEFCREAMER February87
STORE BDEFCREAMER January96
STORE BDEFNON-DAIRY CREAMER March14
STORE BDEFNON-DAIRY CREAMER February22
STORE BDEFNON-DAIRY CREAMER January33

 

 

Expected result

Store A  
Total ABC for Store A182,795100%
   
Category  
Sour Cream137,87975.4%
Milk44,91624.6%
   
Store B  
Total ABC for Store B22,748100%
   
Category  
Milk3,04413.4%

Still no coding required.

 

lbendlin_0-1712006423984.png

 

 

Thank you! Do you know of a way to show each category as a card instead of within a table?

will all cards be subject to the same filter?

All cards I want to filter - to see the same Store and Brand but each card would have a different category. For example:

1 card:  shows the % of milk/ overall Volume for Brand ABC in store A = 27.6%

2 card:  shows the % of sour cream/ overall Volume for Brand ABC in store A = 72.4%

lbendlin_0-1712096569449.png

 

lbendlin
Super User
Super User

You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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