Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

it Calculate increase from previous row

Hi, 

 

I am trying to calculate the increase of my "Median of TTR" column over the grade before and show it in a new column:

 

So for grade 06 it would be: (18.049,42 (G06) - 9824,74 (G05)) / 9824,74 (G05) = 84%. 

 

How could I create a measure like this?

 

Please notice that for some cuts of my data, some grades will be missing, so it might go from grade 05 to 08, for example. In these cases, I won't need to show any increment.

 

Thanks!

2 Replies

  • Anonymous , There is row manipulation

     

    Create a rank as a column on the grade in table

     

    Rank column = rankx(all(Table),[grade],,asc,dense)

     

    Now use rank to have previous. row.

     

    This grade= CALCULATE(sum('Table'[TTR]),filter(ALL('Table'[grade]),'Date'[Rank column]=max('Date'[Rank column])))
    Last grade= CALCULATE(sum('Table'[TTR]),filter(ALL('Table'[grade]),'Date'[Rank column]=max('Date'[Rank column])-1))

     

    or

     

    This grade= CALCULATE(sum('Table'[TTR]),filter(ALL('Table'[Rank column]),'Date'[Rank column]=max('Date'[Rank column])))
    Last grade= CALCULATE(sum('Table'[TTR]),filter(ALL('Table'[Rank column]),'Date'[Rank column]=max('Date'[Rank column])-1))

     

    same as what I did in WOW

     

    https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

  • FarhanAhmed's avatar
    FarhanAhmed
    Icon for Community Champion rankCommunity Champion

    How is your data stored ?

    What is the table structure?

    What is the criteria of previous row ? is it grade or is it latest record via date ? A comp Grade is unique ?

    Sample data of your full table would be nice.