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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
DeepDive
Helper IV
Helper IV

Category wise YTD of Top 5.... Top 5 based on Total

Hi All, I want to show top 5 categories with YTD and Total. I wan to show top categories based on Total not based on YTD.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DeepDive ,

You can have ytd like

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

overall Sales = CALCULATE(SUM(Sales[Sales Amount]),all('Date'))

 

On overall sales you can have rank or top N for category and filter

Top 5 category Rank = CALCULATE([overall  Sales],TOPN(10,all(Item[category ]),[overall  Sales],DESC),VALUES(Geography[Item category ]))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@DeepDive ,

You can have ytd like

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

overall Sales = CALCULATE(SUM(Sales[Sales Amount]),all('Date'))

 

On overall sales you can have rank or top N for category and filter

Top 5 category Rank = CALCULATE([overall  Sales],TOPN(10,all(Item[category ]),[overall  Sales],DESC),VALUES(Geography[Item category ]))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Thanks, @amitchandak, very thanks for this information.

 Really helpful post.

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.