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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Need to create logic of TOP N columns considering multiple columns.

Hi Teams,
Could you please provide solution for below issue:



DATA     Result needed 
opportunity categtegoryARRweek start  TOPN- commitTOPN- upside
acommit 10005/7/2021  2 
bcommit 244345/7/2021  1 
hupside10005/7/2021   2
cupside34245/7/2021   1
dcommit 06/7/2021  2 
eupside2443246/7/2021   1
fcommit 2316/7/2021  1 
gupside43557/7/2021   1
hcommit 2143247/7/2021  1 
jcommit 3427/7/2021  2 
kupside35257/7/2021   2


Need help in fining top 10 opportunities for "commit" and top5 for "upside" as per ARR for every week start.



=> created the below mentioned logic but it is not considerig week start and will give TON for whole data.
Also it is ignoring ARR=0 while raking the opportunities, not able to undertsand the reason.


Upside_top_weekly_5 =
VAR RANKING2 = IF((Opportunity[Category]= "Upside" && Opportunity[ARR] <> BLANK()), RANKX(FILTER(Opportunity, Opportunity[Category]= "Upside" && Opportunity[ARR] <> BLANK())), Opportunity[ARR] , ,DESC, Dense), BLANK())
RETURN
IF(RANKING2<6, RANKING2, BLANK())


 

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to use the following measure:

 

Upside_top_weekly_5 =
VAR RANKING2 =
    IF (
        Opportunity[Category] = "Upside"
            && Opportunity[ARR] <> BLANK (),
        RANKX (
            ALL ( Opportunity[Opportunity] ),
            CALCULATE (
                SUM ( Opportunity[ARR] ),
                FILTER (
                    Opportunity,
                    Opportunity[Category] = "Upside"
                        && Opportunity[ARR] <> BLANK ()
                )
            ),
            ,
            DESC,
            DENSE
        ),
        BLANK ()
    )
RETURN
    IF ( RANKING2 < 6, RANKING2, BLANK () )

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
d_gosbell
Super User
Super User

I think this will be simpler if you break it into a couple of measures.

 

I created an [Upside ARR] to only return the value of ARR for category = upside

 

Upside ARR = calculate(SUM(Opportunity[ARR]), KEEPFILTERS(Opportunity[Category]="Upside"))
 
You could potentially roll this into your ranking measure, but it makes it easy to test the pieces of your calc when it's separate.
 
Then I adjusted your ranking measure as follows:
 
Upside_top_weekly_5  =
var currentWeek = SELECTEDVALUE(Opportunity[week start])
VAR RANKING2 = RANKX(FILTER(ALL(Opportunity), Opportunity[Category]= "Upside" && Opportunity[ARR] <> BLANK() && Opportunity[week start] = currentWeek), Opportunity[ARR] , [Upside ARR] ,DESC, Dense)
RETURN
IF(RANKING2<6 && NOT(ISBLANK([Upside ARR])), RANKING2, BLANK())
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to use the following measure:

 

Upside_top_weekly_5 =
VAR RANKING2 =
    IF (
        Opportunity[Category] = "Upside"
            && Opportunity[ARR] <> BLANK (),
        RANKX (
            ALL ( Opportunity[Opportunity] ),
            CALCULATE (
                SUM ( Opportunity[ARR] ),
                FILTER (
                    Opportunity,
                    Opportunity[Category] = "Upside"
                        && Opportunity[ARR] <> BLANK ()
                )
            ),
            ,
            DESC,
            DENSE
        ),
        BLANK ()
    )
RETURN
    IF ( RANKING2 < 6, RANKING2, BLANK () )

 

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

 

Best Regards,

Dedmon Dai

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.