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
vmakhija
Post Prodigy
Post Prodigy

DAX question - Filter along with Top N

Hello

I have a unique requirement where user will have 2 slicers -

1. To select top n (options can be top 3, top 5, top 7, etc)

2. Debt or Non-Debt (data regarding this - I will explain below) - this will be single select

 

Consider the snapshot of the sample data as below -

CompanyMarket CapDebt/No DebtDate
Orange4.9No Debt8/31/2020
Orange2.9No Debt8/30/2020
Orange6No Debt8/29/2020
Orange9.2Debt8/28/2020
Orange8.4Debt8/27/2020
Orange2.8Debt8/26/2020
Orange2.1No Debt8/25/2020
Orange4.2Debt8/24/2020
Orange8.1Debt8/23/2020
Orange0.9Debt8/22/2020
Orange0.3No Debt8/21/2020
Orange3.3No Debt8/20/2020
Orange7.2No Debt8/19/2020
Orange5No Debt8/18/2020
Orange3.5Debt8/17/2020
Orange8.5No Debt8/16/2020
Orange8Debt8/15/2020
Orange5.2No Debt8/14/2020
Orange7.2No Debt8/13/2020
Orange9.1Debt8/12/2020
Orange6.2No Debt8/11/2020
Orange4.4Debt8/10/2020

 

There can be 2 scenarios -

1. If user selects "Debt" and top 5, the expected output is 

CompanyCumulative MarketCapDate
Orange16.28/31/2020
Orange14.68/30/2020
Orange18.98/29/2020
Orange17.98/28/2020
Orange17.98/27/2020

 

In this case, only the top 5 dates where Debt/No Debt is "Debt" will be considered. Thus, it shows cumulative marketcap of top 5 Debt dates corresponding to each date on a rolling basis.

 

2. If user selects "No Debt" and top 5, the expected output is 

CompanyMarketCapDate
Orange32.78/31/2020
Orange32.78/30/2020
Orange32.78/29/2020
Orange32.78/28/2020
Orange24.48/27/2020

 

In this case, only the top 5 dates where Debt/No Debt is "No Debt" will be considered. Thus, it shows cumulative marketcap of top 5 "No Debt" dates corresponding to each date on a rolling basis.

 

I tried to use TOPN in my measure, but didn't get it to work.

 

Anyone tried this use case before or have any ideas?

 

Regards

6 REPLIES 6

thanks @amitchandak for providing these useful links.

 

Actually, in my case, the dates will be not continous, so I am having a problem to use RANKX function.

 

Regards

Hey @vmakhija ,

 

please explain the expected outcome

  • the dates seleceted if the user is selecting top 5 and top 3 no debt and each time the calculation for the cumulative market cap
  • the dates seleceted if the user is selecting top 5 and top 3 debt and each time the calculation for the cumulative market cap

make sure that the explanation matches the sample data you provided.

 

I'm also wondering if there will be more than one company and if the data of a 2nd company will affect the calculation of the cumulative market cap and the selection of dates.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens 

thanks for your reply

 

Here is an explanation -

1. the dates seleceted if the user is selecting top 5 and top 3 no debt and each time the calculation for the cumulative market cap

In this case, the dates selected for the calculation has to be -

a. for Top 5 and "No debt", it will be 8/31/2020, 8/30/2020, 8/29/2020, 8/25/2020 and 8/21/2020.

b. for Top 3 and "No debt", it will be 8/31/2020, 8/30/2020 and 8/29/2020.

 

2. the dates seleceted if the user is selecting top 5 and top 3 debt and each time the calculation for the cumulative market cap

In this case, the dates selected for the calculation has to be -

a. for Top 5 and "debt", it will be 8/28/2020, 8/27/2020, 8/26/2020, 8/24/2020 and 8/23/2020.

b. for Top 3 and "debt", it will be 8/28/2020, 8/27/2020 and 8/26/2020.

 

Yes, there will be more than one companies.

The data for one company will be mutually exclusive from another company. Each company's data will be looked at as 1 group for the DAX calculation.

 

Regards

Hey @vmakhija ,

 

please provide the calculation for the cumulative Market Cap for Top 5 No debt and Top 5 Debt as the value for the expected result from your initial post are not totally clear, at least not to me.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens 

Here is the calculation.

 

1. For Top 5, No Debt, it will be 4.9 + 2.9 + 6 + 2.1 + 0.3 = 16.2

8/31/2020 -> 4.9

8/30/2020 -> 2.9

8/29/2020 -> 6

8/25/2020 -> 2.1

8/21/2020 -> 0.3

 

2. For Top 5, Debt, it will be 9.2 + 8.4 + 2.8 + 4.2 + 8.1 = 32.7

8/28/2020 -> 9.2

8/27/2020 -> 8.4

8/26/2020 -> 2.8

8/24/2020 -> 4.2

8/23/2020 -> 8.1

 

Hope it is clear now.

 

Basically, I want to rank the non-consecutive dates based on the "Debt/No Debt" filter.

And then use the top 5 or top 3 or top n using this rank. Then calculate the cumulative market cap.

 

Regards

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.