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

Calculated Column for Top 3 Spenders Month by Month based on BU and Total Spend

Hi Everyone, 

 

I have a table like this in my dashboard, I want to create a calculated column that writes Top Spender based on Total Amount Spent per person in a each month seperately for people who work in the same business and based on the top 3 spenders amounts, which ca yield the result below like in the last column. 

 

Appreciate any help on this!

 

NameSpendBusinessDate 
Max100Marketing24-Jan
Zak20Accounting24-Jan
Sophia90Marketing24-Jan
Hana40Accounting24-Jan
Mark70Marketing24-Jan
Zak10Accounting24-Jan
Max55Marketing24-Jan
Sophia25Accounting24-Jan
Philip5MarketingJan-24
Zak60Accounting23-Dec
Mark30Marketing23-Dec
Hana80Accounting23-Dec
Mark30Marketing23-Dec
Zak50Accounting23-Dec
Mark15Marketing23-Dec
Hana50Accounting23-Dec
Max10Marketing23-Dec
Zak40Accounting23-Dec
Max5Marketing23-Dec
Hana200Accounting23-Dec

 

This result table would look something like the below 

Click Marketing Slicer

 

Click January in Date Slicer 
NameSpendBusinessTop Spender flagTop Spender_JanTop Spender Repeats from past 2 months
Max155MarketingTop Spender12
Mark70MarketingTop Spender12
Sophia90MarketingTop Spender11
1 ACCEPTED SOLUTION

That should not be happening.  I do not know the mistake you are commting.  Based on the data you shared with me, the file which i shared in my previous message does the job.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

13 REPLIES 13
kalkhudary
Helper III
Helper III

@Ashish_Mathur I think the top spender flag is the same as the Jan_Top Spender. Probably we can drop it and Use Jan_Top Spender, Dec_Top Spender and then the final Column which is the sum of occurrences for Jan and Dec nevertheless the date slicer is set for Jan for example. Any thoughts on how we can DAX the intended result.

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1714346098448.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur I am super thankful for your help on this, really so happy. However, I have tested the measure of occurences as top spender and doesn't seem to perform the intention. If you changed in the file the "measure" to Top 1 to zoom more on the case, you see that the measure is giving you the number of time the person showed in the file, not the number of times where a person showed as a top spender whether top 3 or top 1.

 

Top 3 spenders = CALCULATE([S],TOPN(1,ALL(Data[Name]),[S],DESC),VALUES(Data[Name]))
 
See below example, Mark showed as Top Spender in December. In January, Max did not show as top spender in the previous month, so the value should be 0 but shows as 2 here as it is counting how many times Max overall showed in the spenders list whether he is top spender or not.
 
Top N.PNGTop N_1.PNG
 
My intention is to show how many times a person did occur as a top spender based on previous 3 months for example. Anything we can adjust in the Dax to make it work.
 
Thanks Ashish.

Hi,

Can you live with this?  The 2 measures will tell you what the rank was in the current and in the previous month.

Hope this helps.

Ashish_Mathur_0-1714434672441.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur I wish this would solve it. I need to find a Dax that basically count the times based on past 3 months where an employee from the top 3 spenders showed as a top spender. If John showed as Top Spender in Jan and was a top spnder in Dec and November,the value should be 3 and if he showed only in Jan, the value should be 1 - taking into consideration that we filtered date to Jan.

 

I am trying to find a method to dax it, not successful so far, trying with dateadd function now.

Hi,

Try this file.  The measure checks in the selected month and in 1 month prior.

Ashish_Mathur_0-1714562599863.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur Thank you so much that seems to work for previous month. Quick question, when I applied the measure to my data, It seems it is giving me the counts not only based on top 3 but also looking into the other employees who are on the list and count them as part. Any idea what to include in the measure to restrict it only to look at top 20 from previous month. Any function tha can help do that. 

That should not be happening.  I do not know the mistake you are commting.  Based on the data you shared with me, the file which i shared in my previous message does the job.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kalkhudary
Helper III
Helper III

@Ashish_Mathur Thanks for helping me break my thoughts, I have included the table with expected result table that I would need to show. One for Top Spender flag, one for the occurrence during the chosen month , and one for the ocurrence of this person in top spender list from previous month.

 

Hope that clears it more. How can we Dax the 3 critria, I am struggling since 2 days to fnd a proper and neat solution.

What do the 1's in the "Top Spender_Jan" column signify?  Why is ths column needed when you already have the "Top Spender flag" column?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kalkhudary
Helper III
Helper III

@Ashish_Mathur My final intention is to create a measure that would count instances of top spender based on past 3 months. So if Max showed in Jan, Dec, and November as Top Spender, then he has 3 instances of repeatitive Top Spender. Any thoughts how to reach this outcome. This is the only way that came to my mind so a calculated column would help reach this outcome.

Hi,

Based on the table that you shared in the first post, show the expected result, with an explanation.  Assume that there is no "Top 3 Spenders Month by Month based on BU and Total Spend" column in your dataset.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Why do you want to create a calculated column formula?  Why not a measure?  See this article - Vendor Analysis In Inventory Management Dashboards | Master Data Skills + AI (enterprisedna.co)


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.