Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Difference between two values in the came column.

Hi there.

 

I am fairly new to PowerBI and can't seem to get this right.

 

I want to get the difference between two values in the same column and that will show in a new column.

 

See data table below

YearProjected No. of SwimmersDifference
2021335196.8 
2026354965.5+19,768.7
2031370396.1 
2036383843.7 
2041394566.4 
2046403489.4 
2051412977.8 

 

What would be the DAX for this?

  • Anonymous 

    sry, typo error in the DAX. pls change minx to maxx

    Column =
    var last=MAXX(FILTER('Maintain Participation','Maintain Participation'[Projected No. of Swimmers]<EARLIER('Maintain Participation'[Projected No. of Swimmers])),'Maintain Participation'[Projected No. of Swimmers])
    return if(ISBLANK(last),blank(),'Maintain Participation'[Projected No. of Swimmers]-last)

5 Replies

  • Anonymous 

    pls try this

     

    Column = 
    var last=minx(FILTER('Table (3)','Table (3)'[Projected No. of Swimmers]<EARLIER('Table (3)'[Projected No. of Swimmers])),'Table (3)'[Projected No. of Swimmers])
    return 'Table (3)'[Projected No. of Swimmers]-last

     

    if you want the blank for first row. try this

    Column = 
    var last=minx(FILTER('Table (3)','Table (3)'[Projected No. of Swimmers]<EARLIER('Table (3)'[Projected No. of Swimmers])),'Table (3)'[Projected No. of Swimmers])
    return if(ISBLANK(last),blank(),'Table (3)'[Projected No. of Swimmers]-last)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi there.

       

      Thank you for your reply.

       

      It doesn't seem to be working for me as I am getting a message that "The end of the input was reached".

       

      The table name is Maintain Participation if you could try again using that as the name of the table?