Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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?

1 ACCEPTED SOLUTION

@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)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@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

 

1.PNG

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)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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?

@Anonymous 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @ryan_mayu 

 

That worked thank you, however it is getting the difference between 2021 and the other years and adding them on top of each other. I just want the difference between each of the years (i.e. 2026-2021, 2031-2026 etc.) I have completed more of the data below if it makes more sense. Sorry if i wasn't clear originally.

 

See data table below

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

@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)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.