Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I want to calculate the total number of convid cases by date. however the formula below throws an error. I think it might relates to the language setup of my Power BI or my laptop. however, i don't know how to fix it.
Solved! Go to Solution.
OK, you generally don't use EARLIER in a measure unless you are using ADDCOLUMNS.
So, the next question, what are you trying to accomplish? If you just do SUM([Total confirmed cases of COVID-19] and you put that in a visual along with your Date column, you should get the total confirmed cases for every date. Is that what you want?
That's odd, the error message doesn't seem to match. First question, is this supposed to be a measure or a column?
I meant to write a measure.
OK, you generally don't use EARLIER in a measure unless you are using ADDCOLUMNS.
So, the next question, what are you trying to accomplish? If you just do SUM([Total confirmed cases of COVID-19] and you put that in a visual along with your Date column, you should get the total confirmed cases for every date. Is that what you want?
You are right. when I use the earlier function in the column calculation, it works!
I also remember the reason behind, ealier function scann the day column line by line to get the current "day" as a filter condition. Therefore it can only be used in column calculation.
Yes, unless you use ADDCOLUMNS in a measure, then you can use EARLIER when adding a column.
I don't think earlier function is only used in new column. I have seen examples using earlier function to create a measure of sales revenue by product category, and use this measure to create visuals with slicers.
In my case, i want to know how number of crono cases grows from day x to day x+1. Using China and Italy data, it turns out before lockdown, the crono cases increase 30-40% per day, 5 days after lockdown, the increase rate declines. i would like to see if it's the similar case with other countries. therefore i want to create the growth rate measure, track growth rate by days and country in power visual.
Yes, that's why I said generally! 🙂 It can be done, it is just not that common.
If I may make a suggestion, I would try something like:
% Growth =
VAR __Date = MAX('Table'[Date])
VAR __Today = SUM([Total confirmed cases of COVID-19])
VAR __Yesterday = SUMX(FILTER('Table',REMOVEFILTERS('Table'[Date]),[Date]=(__Date - 1) * 1.),[Total confirmed cases of COVID-19])
RETURN
DIVIDE(__Today - __Yesterday,__Yesterday,0)
You should be able to place that into a visual along with Date.
User | Count |
---|---|
141 | |
113 | |
104 | |
78 | |
64 |
User | Count |
---|---|
136 | |
125 | |
107 | |
70 | |
61 |