Forum Discussion

Nissa23's avatar
Nissa23
Icon for Helper I rankHelper I
3 years ago
Solved

Top N by row (dates) from multiples columns

Hi,

 

I'd like to do a visual showing only Top (N) using multiples columns.

 

datesCol1col2col3col4 Wanted Result in visual
2023-04-2025201545 col1 :25; col4: 45
2023-04-2112351034 col4: 34; col2: 35
2023-04-2245223648 45;48
2023-04-2312473114 47;31
2023-04-2456203312 56;33

 

I'm using the filter but I can just choose one column not all others :

Do you have idea how to do it ?

 

Thanks

Nissa

  • Hi Nissa23 ,

     

    Please try:

    First Unpivot your data:

    Output:

    Then apply the measure:

    TOPN_Value = 
    var _a = TOPN(2,FILTER(ALL('Table'),'Table'[dates]=SELECTEDVALUE('Table'[dates])),[Value],DESC)
    return IF(SELECTEDVALUE('Table'[Attribute]) in SELECTCOLUMNS(_a,"Attribute",[Attribute]),SUM('Table'[Value]))

    Final output:

    Best Regards,

    Jianbo Li

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

1 Reply

  • Hi Nissa23 ,

     

    Please try:

    First Unpivot your data:

    Output:

    Then apply the measure:

    TOPN_Value = 
    var _a = TOPN(2,FILTER(ALL('Table'),'Table'[dates]=SELECTEDVALUE('Table'[dates])),[Value],DESC)
    return IF(SELECTEDVALUE('Table'[Attribute]) in SELECTCOLUMNS(_a,"Attribute",[Attribute]),SUM('Table'[Value]))

    Final output:

    Best Regards,

    Jianbo Li

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