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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Picking top 10 based on one year but need to have another years as well

Hi, 

 

I am working on matrix to create the net sales data of 4 years (2019,2020,2021,2022) but I want to do the top N only on one year and still want to see the other years as well

 

MaliniB_0-1655955499779.png

so I want only the 2021 year to be filtered by top N rest of the years can remain the there without affected by top N filter on 2021? is something like this possible 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below, and I hope it helps to provide some ideas on how to create a new measure for your data model.

Untitled.png

 

Quantity total conditional measure: =
VAR _topthreetable2021 =
    TOPN (
        3,
        FILTER ( ALL ( Data ), Data[Year] = 2021 ),
        CALCULATE ( SUM ( Data[Quantity] ) ), DESC
    )
RETURN
    IF (
        HASONEVALUE ( 'Year'[Year] ),
        IF (
            SELECTEDVALUE ( 'Year'[Year] ) = 2021,
            CALCULATE ( SUM ( Data[Quantity] ), KEEPFILTERS ( _topthreetable2021 ) ),
            SUM ( Data[Quantity] )
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI Jihwan, 

 

thanks for the reply. I want the other following years values remain the same (like in excel we have an option to sort only one column and rest of the columns will have values corresponding to the sorted column. similarly in power Bi I want t to pick the top N based on 2021 data. 

 

I also tried the formula you suggested but I get errors which I cannot understand. I am using proper syntax and parameters  but still shows syntax....

MaliniB_0-1655992990139.png

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below, and I hope it helps to provide some ideas on how to create a new measure for your data model.

Untitled.png

 

Quantity total conditional measure: =
VAR _topthreetable2021 =
    TOPN (
        3,
        FILTER ( ALL ( Data ), Data[Year] = 2021 ),
        CALCULATE ( SUM ( Data[Quantity] ) ), DESC
    )
RETURN
    IF (
        HASONEVALUE ( 'Year'[Year] ),
        IF (
            SELECTEDVALUE ( 'Year'[Year] ) = 2021,
            CALCULATE ( SUM ( Data[Quantity] ), KEEPFILTERS ( _topthreetable2021 ) ),
            SUM ( Data[Quantity] )
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Anonymous
Not applicable

I figured it out its working now . thanks for the help 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.