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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
LUCASM
Helper IV
Helper IV

DIVIDE (SHARE)

I am trying to createa Label which shows the share of the top 50 Models over a total data set.

When I do this over the last month I have no problem

I have a calculation for this month 

 

 

C_Unit TW = CALCULATE(
SUM(
'My Table'[Sales Units]),
FILTER('My Table,'My Table'[Index_Month] = 1))

 

 

 

and a calculation for Top 50 This Month

 

 

C_Unit Top50 TW = CALCULATE(
    SUM('My Table'[Sales Units]),
        TOPN(50,
        GROUPBY('My Table',My Table[Short Name],My Table[Brand Group],My Table[Comparison]),
        CALCULATE(SUM('My Table'[Sales Units]))), FILTER ('My Table','My Table'[Index_Month] = 1))

 

 

 

I then DIVIDE one by the other

 

 

C_Unit Share TW = DIVIDE ([C_Unit Top50],[C_Unit TW])

 

 

 

 

My Problem is I need to do the same over 3 months BUT it MUST be based on the TOP 50 Products (aka Short Name) in the Current Month (aka Index_Month = 1) 

 

I think need to ammend this calcuation

 

 

C_Unit Top50 3M = CALCULATE(
    SUM('My Table'[Sales Units]),
        TOPN(50,
        GROUPBY('My Table',My Table[Short Name],My Table[Brand Group],My Table[Comparison]),
        CALCULATE(SUM('My Table'[Sales Units]))), 
        FILTER ('My Table','My Table'[Index_Month] = 1|| 'My Table'[Index_Month] = 2 ||'My Table'[Index_Month] = 3 ||'My Table'[C_Rev Top50 TW]))

 

 

 

 to include this filter

[Short Name] Top 50 by [C_Unit_TW]

but I'm struggeling to work out how to do this

 

2 REPLIES 2
amitchandak
Super User
Super User

@LUCASM , Assume you need TOPN based on a measure M1, may be 1 month, 1 year or 3 months and you want to have values of the month based on that , say you have measure rolling 3 for that

 

Try a measure like

 

CALCULATE([Rolling 3],TOPN(50,Summarize(allselected('My Table') ,My Table[Short Name],My Table[Brand Group],My Table[Comparison]),[This Year],DESC),Summarize('My Table',My Table[Short Name],My Table[Brand Group],My Table[Comparison]))

 

Rolling 3 can be like

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I think there is something amis here

 

 

CALCULATE(
[Rolling 3],
TOPN(50,
Summarize(allselected('My Table') ,My Table[Short Name],My Table[Brand Group],My Table[Comparison]),
[This Year],DESC),
Summarize('My Table',My Table[Short Name],My Table[Brand Group],My Table[Comparison]))

 

 

[This year] does not exist either in the summarise above nor in my table

I attempted to work out what you were doing and decided that you were sorting the table by Sales Units DESC to pick up the Top 50 by Sales Units

But to do that I had to put the Sales Units into the SUMMARISE and the resulant number is way to low.

 

I like the Rolling 3 calculation I do have a date field so I used that and the 3 month total is spot on.
Now I still need to calculate the TOP 50 SUM([sales units]) but only include models that exist in the current month 

 

This is what I did - not correct

 

 

SUM_TOP_50_UNITS_3_MONTHS = 
CALCULATE([Rolling 3],
TOPN ( 50, SUMMARIZE(ALLSELECTED('My_Table'),My_Table[Short Name],'My_Table'[Brand Group],'My_Table'[Comparison],My_Table[Sales Units]),
'My_Table'[Sales Units],DESC),
SUMMARIZE('My_Table',My_Table[Short Name],My_Table[Brand Group],My_Table[Comparison]))

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.