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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
owlet0214
Helper I
Helper I

Difference from previous cell

Hello,

 

I want to make a custom column that calculates the difference from the previous cell.

The testedPositive is not the increasing number of people on that day, but the cumulative total up to that day.

 

diff3.PNG

 

What I want to get is the increased number of people in each city from the day before.

That's the Difference column in the table below.

 

diff4.PNG

 

 

I know it's not a DAX-friendly process, but please help.

 

 

 

1 ACCEPTED SOLUTION

Unless it is prefecture columns throwing things off I would think:

diff = [testedPositive] - maxx(filter('prefectures4',[prefectureNameE]=earlier([prefectureNameE]) && [Last date] <earlier([Last date])),[testedPositive])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@owlet0214 , prefer to create a date from the year , month and day and create two new columns like

 

Last date = maxx(filter(table,[city]=earlier([city]) && [Date] <earlier([Date])),[Date])
diff = [tested positive] - maxx(filter(table,[city]=earlier([city]) && [Date] <earlier([Last Date])),[tested positive])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks a lot !

 

I haven't gotten the expected number yet, but I think it's getting closer to the correct answer.

I will try a little more.

 

diff5.PNG

I use below.

 

Last date = maxx(filter('prefectures4',[prefectureNameE]=earlier([prefectureNameE]) && [YYYYMMDD2] <earlier([YYYYMMDD2])),[YYYYMMDD2])


diff = [testedPositive] - maxx(filter('prefectures4',[prefectureNameE]=earlier([prefectureNameE]) && [YYYYMMDD2] <earlier([Last date])),[testedPositive])

Hello, I have an identical situation, and I already managed to rescue the previous value with respect to the date, but I can not do it by differentiating it by city, I do not know if you can explain to me how it was that you used the variable of [prefectureNameE] and earlier([prefectureNameE]) for this case.

Best regards.

Unless it is prefecture columns throwing things off I would think:

diff = [testedPositive] - maxx(filter('prefectures4',[prefectureNameE]=earlier([prefectureNameE]) && [Last date] <earlier([Last date])),[testedPositive])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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