Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Top N with dynamic start and end point

Hi I am quite new to Power BI

 

I have an extensive range of data which I would like to look at the Top N with a dynamic start and end.

For example,

Item Name          Stock             6 Month Sales

Item 1                     100               500

Item 2                     2000            600

Item 3                     5                     15

...

Item 4000            100               500

Item 4001            100               500

But I would like to start at Item 1001 compared to item 1

Item Name          Stock             6 Month Sales

Item 1000            100               510

Item 1001            110               511

Item 1002            111               500

Item 1003            112               510

...

Item 3000            100               500

Item 3000            100               500

Is this possible? And would I be able to actively change this depending on needs

  • Hi Anonymous ,

     

    You can split the item number into a new column in power query and use it as a slicer to limit the start and end range.

    Create an unrelated number table as the top n slicer.

    Table 2 = GENERATESERIES(1,50,1)

    Then create a measure and apply it in visual level filter.

    Measure = IF(RANKX ( 
                ALLSELECTED('Table'),
               [sum_sales]
            )<=SELECTEDVALUE('Table 2'[rank]),
            1,0)

    Sample .pbix 

     

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

2 Replies

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    You can split the item number into a new column in power query and use it as a slicer to limit the start and end range.

    Create an unrelated number table as the top n slicer.

    Table 2 = GENERATESERIES(1,50,1)

    Then create a measure and apply it in visual level filter.

    Measure = IF(RANKX ( 
                ALLSELECTED('Table'),
               [sum_sales]
            )<=SELECTEDVALUE('Table 2'[rank]),
            1,0)

    Sample .pbix 

     

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