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
venug20
Resolver I
Resolver I

DAX - TOP N, BOTTOM N, Sales

Hi Everyone,

 

 

 

1. I want TOP 1 sales by customer based on "State Level"  where Growth 200%.

 

2. I want TOP 1 sales by customer based on "District Level"  where Growth 200%.

 

3. I want Bottom 1 Sales by Customer based on "State Level" where Growth 0%.

 

4. I want Bottom 1 Sales by Customer based on "District Level" where Growth 0%.

 

Sample data available in this link

 

Please help on this.... Thaks in advance....

 

Regards

Venu

 

1 ACCEPTED SOLUTION

Hi @venug20,

 

How about this solution? Please check out the demo in the attachment.

Top =
VAR N = 20
VAR ranks =
    RANKX (
        ALL ( Sheet1 ),
        CALCULATE ( SUM ( Sheet1[Sales Value] ) ),
        ,
        desc,
        DENSE
    )
RETURN
    IF (
        MIN ( Sheet1[Data Level] ) = "State level"
            && MIN ( Sheet1[Growth %] ) = 2,
        IF ( ranks <= N, ranks, BLANK () )
    )
Bottom =
VAR N = 20
VAR ranks =
    RANKX ( ALL ( Sheet1 ), CALCULATE ( SUM ( Sheet1[Sales Value] ) ),, asc, DENSE )
RETURN
    IF (
        MIN ( Sheet1[Data Level] ) = "State level"
            && MIN ( Sheet1[Growth %] ) = 0,
        IF ( ranks <= N, ranks, BLANK () )
    )
DAX_TOP_N_BOTTOM_N_Sales2

Best Regards,

Dale

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

View solution in original post

9 REPLIES 9
venug20
Resolver I
Resolver I

Hi Everyone,

 

Is it possible atleast in this situation.... Please can anyone try

 

1. I want TOP 1 sales by  "State Level" where Growth 200%.

2. I want TOP 1 sales by "District Level" where Growth 200%.

3. I want Bottom 1 Sales "State Level" where Growth 0%.

4. I want Bottom 1 Sales by "District Level" where Growth 0%.

 

Please help on this.... Thaks in advance.... Regards Venu

Unable to access the link!!!

Hi @venug20,

Take a look at the file with your requirement implemented by clicking here

 

Hope this solves your need!!!

@v-jiascu-msft @Thejeswar

 

Thanks for your reply.... I really appreciate your effort...

 

but i want output like below snapshots....

 

I want to show one table for TopN Sales and another table for Bottom N Sales....

 

I am not select any option from Slicer and also i am not doing filters from visual level....

 

If possible Please provide DAX for this requirement...

 

BottomN-District-Growth.jpgTopN-District-Growth.jpg

Hi @venug20,

 

How about this solution? Please check out the demo in the attachment.

Top =
VAR N = 20
VAR ranks =
    RANKX (
        ALL ( Sheet1 ),
        CALCULATE ( SUM ( Sheet1[Sales Value] ) ),
        ,
        desc,
        DENSE
    )
RETURN
    IF (
        MIN ( Sheet1[Data Level] ) = "State level"
            && MIN ( Sheet1[Growth %] ) = 2,
        IF ( ranks <= N, ranks, BLANK () )
    )
Bottom =
VAR N = 20
VAR ranks =
    RANKX ( ALL ( Sheet1 ), CALCULATE ( SUM ( Sheet1[Sales Value] ) ),, asc, DENSE )
RETURN
    IF (
        MIN ( Sheet1[Data Level] ) = "State level"
            && MIN ( Sheet1[Growth %] ) = 0,
        IF ( ranks <= N, ranks, BLANK () )
    )
DAX_TOP_N_BOTTOM_N_Sales2

Best Regards,

Dale

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

@v-jiascu-msft

 

You have done a great job, superb.....

thanks alot...

 

@v-jiascu-msft

 

I am unable to download attached "PBIX" file...

Hi @venug20,

 

Please check out the demo in the attachment. The requirements could be achieved by two measures. And then add several slicers.

Top =
RANKX (
    ALLSELECTED ( Sheet1 ),
    CALCULATE ( SUM ( Sheet1[Sales Value] ) ),
    ,
    desc
)
Bottom =
RANKX (
    ALLSELECTED ( Sheet1 ),
    CALCULATE ( SUM ( Sheet1[Sales Value] ) ),
    ,
    asc
)

DAX_TOP_N_BOTTOM_N_Sales

 

 

Best Regards,

Dale

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

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.