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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Marketeasing
Frequent Visitor

How to create a value from the increment of other values

Hello, I have to calculate a new column CasesDay (red color) as the variation of the accumulated column CasesAcum.

I have more than 1 Name, so I have to calculate the increment for each row of each "Name". The registers are ordered by Name,Date

Thanks in advance

NameDateCasesAcumCasesDay
Afghanistan20/02/2020 0:0000
Afghanistan21/02/2020 0:0000
Afghanistan22/02/2020 0:0000
Afghanistan23/02/2020 0:0000
Afghanistan24/02/2020 0:0011
Afghanistan25/02/2020 0:0010
Afghanistan26/02/2020 0:0010
Afghanistan27/02/2020 0:0010
Afghanistan28/02/2020 0:0043
Afghanistan29/02/2020 0:0040
Afghanistan01/03/2020 0:0051
Afghanistan02/03/2020 0:0072
Afghanistan03/03/2020 0:0070
Afghanistan04/03/2020 0:0070
Afghanistan05/03/2020 0:00114
Afghanistan06/03/2020 0:00165
Afghanistan07/03/2020 0:00215
Afghanistan08/03/2020 0:00221
Afghanistan09/03/2020 0:00220
Afghanistan10/03/2020 0:00220
Afghanistan11/03/2020 0:00242
Afghanistan12/03/2020 0:00240
Afghanistan13/03/2020 0:004016
Afghanistan14/03/2020 0:00400
1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Marketeasing ,

 

Try this code for a new calculated column:

 

CasesDay =
VAR _name = 'Table'[Name]
VAR _date = 'Table'[Date]
VAR _lastDate = CALCULATE(MAX('Table'[Date]); FILTER(ALL('Table'); 'Table'[Name] = _name && 'Table'[Date] < _date))
VAR _lastValue = CALCULATE(SUM('Table'[CasesAcum]); FILTER(ALL('Table'); 'Table'[Name] = _name && 'Table'[Date] = _lastDate))
RETURN 'Table'[CasesAcum] - _lastValue
 
Ricardo


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

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @Marketeasing ,

 

Try this code for a new calculated column:

 

CasesDay =
VAR _name = 'Table'[Name]
VAR _date = 'Table'[Date]
VAR _lastDate = CALCULATE(MAX('Table'[Date]); FILTER(ALL('Table'); 'Table'[Name] = _name && 'Table'[Date] < _date))
VAR _lastValue = CALCULATE(SUM('Table'[CasesAcum]); FILTER(ALL('Table'); 'Table'[Name] = _name && 'Table'[Date] = _lastDate))
RETURN 'Table'[CasesAcum] - _lastValue
 
Ricardo


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

Proud to be a Super User!



Thank you @camargos88 . Perfect!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.