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
RobertO995
Frequent Visitor

Rank of top 2 values in category

Hello,

 

I've searched, but didn't find anything that fit my problem.

 

I have budgets of every store (every store has own ID). Every store is also in some region. I want to create other table that will present only stores with TOP2 budgets in every region.

 

This is my example data:

 

2019-03-01_09h41_47.png

and the result should be like:

Region1 - 101

Region1 - 102

Region2 - 103

Region2 - 104

Region3 - 106

Region3 - 108

 

I tried use GROUPBY function, but then I can obtain only TOP1 store in Region, but cannot apply that solution to have table with 2 stores with the highest budget.

 

Thx for yuor help

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

Hi @RobertO995 

 

you can use the GENERATE function for this:

 

GENERATE(
    ALLNOBLANKROW( Data[Region] ),
    CALCULATETABLE(
        TOPN(
            2,
            SELECTCOLUMNS(Data, "Budget", [Budget], "Store Number", [Store Number]),
            [Budget]
        )
    )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

1 REPLY 1
LivioLanzo
Solution Sage
Solution Sage

Hi @RobertO995 

 

you can use the GENERATE function for this:

 

GENERATE(
    ALLNOBLANKROW( Data[Region] ),
    CALCULATETABLE(
        TOPN(
            2,
            SELECTCOLUMNS(Data, "Budget", [Budget], "Store Number", [Store Number]),
            [Budget]
        )
    )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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.