Forum Discussion
Calculating daily differences
- 5 years ago
Hi ripstaur ,
First create an index column;
Then create a column as below:
Daily Cases = VAR _maxvalue = CALCULATE ( MAX ( 'Table'[Cases] ), FILTER ( 'Table', 'Table'[County] = EARLIER ( 'Table'[County] ) && 'Table'[Index] < EARLIER ( 'Table'[Index] ) ) ) RETURN 'Table'[Cases] - _maxvalueAnd you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my reply as a solution!
Thanks, Jos,
I tried this, copying your code into the Advanced Editor, and I ended up with this:
If I expand all the columns in the "Data" column, I get the following:
Not sure where I'm going wrong....
Oh...I didn't get it all. Beyond Data.Column6 I have:
It's probably worth noting that the index column contains nothing but zeros, and the Custom column is all Errors.
Another note: My original query included steps to promote the first column as headers, the "change type" commands that always follow promoting headers, and a command to remove column 5 (a blank column in my source). When I added your code after those lines, I got exactly the same result as I did when I just wrote your code in after the source lines.
- Jos_Woolley5 years ago
Solution Sage
"Another note: My original query included steps to promote the first column as headers, the "change type" commands that always follow promoting headers, and a command to remove column 5 (a blank column in my source). When I added your code after those lines, I got exactly the same result as I did when I just wrote your code in after the source lines."
Yes, you should keep your original steps in. And when you added my code in, did you make sure that the (previous) step being referenced in my first line was the last of your initial steps (and not the first)?
Regards