Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

filtering a table with topn

Hello

Can please someody help me to resolve a problem : i get a table but when i use my if parametre to filter it i get all values and not filtered
I use this measure : 

SUMX(TOPN('Paramètre'[Valeur Paramètre];BASE;BASE[Rank];ASC);BASE[ MARGE ACT])
And in my BASE table i created a Rank column to reference it in my measure (
Rank = RANKX(BASE;BASE[ MARGE ACT];BASE[ MARGE ACT];ASC;Dense)



 

  • Anonymous's avatar
    Anonymous
    6 years ago

    It seems like to be resolved
    By putting a rank column with this measure = 

    RANKX(FILTER(BASE;BASE[Date]=EARLIER(BASE[Date]));BASE[ MARGE ACT];;ASC)
    I can group up my base by year so when i filter it by year my table work nice

5 Replies

  • Try like

    var _max =max('Paramètre'[Valeur Paramètre])
    // var _max =maxx('Paramètre','Paramètre'[Valeur Paramètre])
    SUMX(TOPN(_max;BASE;BASE[Rank];ASC);BASE[ MARGE ACT])
      • Anonymous's avatar
        Anonymous
        Not applicable

        Actually even by putting a measure selectedvalue it doestn work. 'Table'[Value] - is a list of values from 1 to X

        SUMX(
        TOPN(SELECTEDVALUE('Table'[Value]);BASE;BASE[ MARGE ACT];ASC);BASE[ MARGE ACT])
    • Anonymous's avatar
      Anonymous
      Not applicable

      So i could find a solution as i suppose ( not sure 😃 ) by using a measure : 

      CALCULATE(
      SUMX(
      TOPN('Paramètre'[Valeur Paramètre];BASE;BASE[Rank];ASC);BASE[ MARGE ACT]);
      FILTER(BASE;BASE[ MARGE ACT]<=0&&BASE[Rank]<='Paramètre'[Valeur Paramètre]))
      NOW the issue is that i cant filter by years : on my screens u see that while year filter inst applied i get all 4 values in my table however when i choose a year i get only two, however i would like to get all 4 values but for a selected year ? What do you think about it ?
      Thanks

       

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      It seems like to be resolved
      By putting a rank column with this measure = 

      RANKX(FILTER(BASE;BASE[Date]=EARLIER(BASE[Date]));BASE[ MARGE ACT];;ASC)
      I can group up my base by year so when i filter it by year my table work nice