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
dMac314
Frequent Visitor

Return Top Product AND total revenue with one DAX measure

Hello All,

 

I am new to DAX and PBI and here as well, this is actually my first question 🙂 so pardon me newbness. I am trying to fgure out a way to return the top product and total revenue (for that product) for the most current month with one measure.

 

Thus far I have the following: 

CurrentSum:= CALCULATE(SUM(Table[Payment]), FILTER(table, table[Payment Year] = YEAR(NOW()) && table[Payment Month] = MONTH(NOW())))



TopProduct:= IF(NOT(ISBLANK([CurrentSum])), IFERROR(CALCULATE(VALUES(table[Product]),TOPN(1, VALUES(table[Product]), [CurrentSum])), "Multiple Products - Tied"))



CurrentProductSum:=(CALCULATE([CurrentSum],TOPN(1, VALUES(table[Product]), [CurrentSum])))

These work just fine but I'd like to be able to return these 2 values (TopProduct and CurrentProductSum) withnone measure and possibly a few at a time e.g. top 10 etc. I can do this easily with page level filters but I'd like to be able to do it dynamically with DAX.

 

Thanks!!!

 

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @dMac314,

 

You can create a Rank measure based on total revenue of each product. Then, add this Rank measure to "visual level filters", set its value to 1 or less than 10.

 

Regards,

Yuliana Gu 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your response @v-yulgu-msft. I understand how to get it done this way but I am looking for a solution that would return everything at once so I wouldnt have to worry about setting any visual level filters. 

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.

Top Solution Authors