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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Django46
Frequent Visitor

Dynamic Axis and Top N - retain rank with legend

Hi Folks,

 

With this DAX i am able to get top n plans but whenever i want to include product inside these plans in legends, I am unable to use top N filter and also it is showing abrupt values 

 
 
TopN Plans =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
RETURN
SWITCH(TRUE(),
SelectedTop = 0,CALCULATE(SUM(viiv_agg_nbrx[nbrx])),
RANKX (
ALLSELECTED( viiv_agg_nbrx[plan name]),
CALCULATE(SUM(viiv_agg_nbrx[nbrx]))
)
<= SelectedTop,
CALCULATE(SUM(viiv_agg_nbrx[nbrx]))
)

Annotation 2020-01-27 202431.pngAnnotation 2020-01-27 202431.png

 

 

I think this is related to DAX but i am not able to figure out, Tried crossjoin but with that also didn't got relevant result 

3 REPLIES 3
sturlaws
Resident Rockstar
Resident Rockstar

Hi again, @Django46,

 

could try to create a measure like this:

topNPlans =
VAR _plan =
    CALCULATE ( SELECTEDVALUE ( Sales[Plan] ) )
RETURN
    CALCULATE (
        COUNTROWS (
            FILTER (
                FILTER (
                    ADDCOLUMNS (
                        VALUES ( Sales[Plan] );
                        "rank"; RANKX ( ALL ( Sales[Plan] ); CALCULATE ( SUM ( Sales[Sales] ) ) )
                    );
                    [rank] <= 2
                );
                Sales[Plan] = _plan
            )
        );
        ALL ( Sales[Product] )
    )

 

and then use this measure as filter for you visual, topNPlans>=1:

Capture.PNG


 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

It is not helping 

 

I would like to help you with your problem. Could you please share your report, or create and share a sample report?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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