Forum Discussion
How can I calculate an increment between two accumulated values?
- 6 years ago
Hi, Try this:
1. Add a Index Column
2. Add a Custom Column
try #"Added Index"{[Index]}[CasesAcum]-#"Added Index" {[Index]-1}[CasesAcum] otherwise 0Regards
Victor
- 6 years ago
Finally I've created a new formula to detect the change of name and that's solved
= Table.AddColumn(#"Índice agregado", "Cases", each if #"Índice agregado"{[Índice]}[#"Name"] = #"Índice agregado"{[Índice]-1}[#"Name"] then #"Índice agregado"{[Índice]}[#"CasesAcum"]-#"Índice agregado"{[Índice]-1}[#"CasesAcum"] else 0)
Thank you Victor
Hi, Try this:
1. Add a Index Column
2. Add a Custom Column
try #"Added Index"{[Index]}[CasesAcum]-#"Added Index" {[Index]-1}[CasesAcum] otherwise 0
Regards
Victor
- Marketeasing6 years agoFrequent Visitor
Hello victor, thank you for your answer, but there are more than one value in the column "Name", and I need to create an index for each "Name" value. Do you know how to do that? Thank you again
- Marketeasing6 years agoFrequent Visitor
Finally I've created a new formula to detect the change of name and that's solved
= Table.AddColumn(#"Índice agregado", "Cases", each if #"Índice agregado"{[Índice]}[#"Name"] = #"Índice agregado"{[Índice]-1}[#"Name"] then #"Índice agregado"{[Índice]}[#"CasesAcum"]-#"Índice agregado"{[Índice]-1}[#"CasesAcum"] else 0)
Thank you Victor
- Marketeasing6 years agoFrequent Visitor
Hello Victor, I've tried the expression that you said but I have big problems with the performance when is loading data.
This solition is non-viable.
Do you know how to create the same column from DAX? because woth powerquery doesn't work.
I don't know why bit to access the rows through the index position is very slow.
Thank toy in advance
- Vvelarde6 years ago
Community Champion
Try with this Dax Calculated Column:
Mycolumn = 'Table'[CasesAcum] - CALCULATE ( FIRSTNONBLANK ( 'Table'[CasesAcum]; 'Table'[CasesAcum] ); TOPN ( 1; FILTER ( 'Table'; 'Table'[Name] = EARLIER ( 'Table'[Name] ) && 'Table'[Date] < EARLIER ( 'Table'[Date] ) ); 'Table'[Date]; DESC ) )Or
Mycolumn = 'Table'[CasesAcum] - CALCULATE ( LASTNONBLANK ( 'Table'[CasesAcum]; 'Table'[CasesAcum] ); FILTER ( 'Table'; 'Table'[Name] = EARLIER ( 'Table'[Name] ) && 'Table'[Date] < EARLIER ( 'Table'[Date] ) ) )Regards
Victor
- Anonymous6 years agoNot applicable
Hi Vvelarde,
Thanks for your answer.
However, If I run the code as you wrote, all the results will shift up for 1 row. We can see that the first row has value, while the last row is null. The target answer should be an empty value in the first row with a value in the last row.
But I think the logic is perfect here, I don't what costs this problem.