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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
_Loic
New Member

Formula problem Rank

Hi,

I try this Measure

_Cumul_III =
    Var Mon_Numero = RANKX(ALLSELECTED(Produits[PRO_CODE]),[_Marges_2])
    Var Best_Products = TOPN(Mon_Numero,'Produits',[_Marges_2])
    Var My_Sum = CALCULATE([_Marges_2],Best_Products)
    RETURN My_Sum
 I want to sum the [_Marges_2] for the ranking :
for example If the rank is 2 : 16 248 988.14 + 14 230 309.54
but my measure give only : 14 230 310
Can you explain to me the reason ?
thanks a lot
_Loic_0-1701860280365.png

 

1 ACCEPTED SOLUTION
BeaBF
Impactful Individual
Impactful Individual

@_Loic Let's try a different approach:
_Cumul_III =
VAR CurrentProduct = SELECTEDVALUE(Produits[PRO_CODE])
VAR Mon_Numero = RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense)
VAR My_Sum =
CALCULATE(
SUM([_Marges_2]),
FILTER(
ALL(Produits[PRO_CODE]),
RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense) <= Mon_Numero &&
SELECTEDVALUE(Produits[PRO_CODE]) = CurrentProduct
)
)
RETURN My_Sum

BBF

View solution in original post

5 REPLIES 5
Loic_Pedro_Hans
Regular Visitor

Hello BBF,

Really great ! 

it works perfectly !!

Thanks .

@Loic_Pedro_Hans  accept the correct answear as a solution please.

 

BBF

BeaBF
Impactful Individual
Impactful Individual

@_Loic  Hi!
Try with:

_Cumul_III =
VAR Mon_Numero = RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense)
VAR SelectedProducts = TOPN(Mon_Numero, VALUES(Produits[PRO_CODE]), [_Marges_2], DESC)
VAR My_Sum = CALCULATE(SUM([_Marges_2]), FILTER(ALL(Produits[PRO_CODE]), RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense) <= Mon_Numero))
RETURN My_Sum

BBF

Thanks a lot,

Your code is interesting, better than me.

But i have the same result ...

_Cumul_IV =
VAR Mon_Numero = RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense)
VAR SelectedProducts = TOPN(Mon_Numero, VALUES(Produits[PRO_CODE]), [_Marges_2], DESC)
VAR My_Sum = CALCULATE([_Marges_2], FILTER(ALL(Produits[PRO_CODE]), RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense) <= Mon_Numero))
RETURN My_Sum
_Loic_0-1701875842692.png

 

BeaBF
Impactful Individual
Impactful Individual

@_Loic Let's try a different approach:
_Cumul_III =
VAR CurrentProduct = SELECTEDVALUE(Produits[PRO_CODE])
VAR Mon_Numero = RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense)
VAR My_Sum =
CALCULATE(
SUM([_Marges_2]),
FILTER(
ALL(Produits[PRO_CODE]),
RANKX(ALLSELECTED(Produits[PRO_CODE]), [_Marges_2], , DESC, Dense) <= Mon_Numero &&
SELECTEDVALUE(Produits[PRO_CODE]) = CurrentProduct
)
)
RETURN My_Sum

BBF

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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