Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am currently doing a COVID-19 reports/dashboard through Power BI. I have this dax formula that will return the new cases for each day. However, the problem with this formula is that I am not able to return the value of the first case - it returns 0. May I ask for suggestion on how to make this formula return the value of first case as well?
Datasource: https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/...
Source code:
New_Cases = VAR Countries = ConfirmedCases[Country/Region] VAR State = ConfirmedCases[Province/State] VAR dates = ConfirmedCases[Date] VAR PrevDay = CALCULATE( MAX(ConfirmedCases[Cases]), FILTER('ConfirmedCases', ConfirmedCases[Country/Region]=Countries && ConfirmedCases[Province/State]=State && ConfirmedCases[Date]<dates)) RETURN IF(PrevDay=0,0, IF(PrevDay>[Cases],0, IF(PrevDay>0,[Cases]-PrevDay)))
Here is the current output:
Solved! Go to Solution.
We got the answer! Sharing the appropriate solution:
We got the answer! Sharing the appropriate solution:
@ironboy0418 , Previous date when cases were 0 (New column)
New_Cases =
VAR Countries = ConfirmedCases[Country/Region]
VAR State = ConfirmedCases[Province/State]
VAR dates = ConfirmedCases[Date]
VAR PrevDay =
CALCULATE(
MAX(ConfirmedCases[dates]),
FILTER('ConfirmedCases',
ConfirmedCases[Country/Region]=Countries && ConfirmedCases[Province/State]=State && ConfirmedCases[Date]<dates && ConfirmedCases[New_Cases]=0))
RETURN
PrevDay
1st date when case were 0
New_Cases =
VAR Countries = ConfirmedCases[Country/Region]
VAR State = ConfirmedCases[Province/State]
VAR dates = ConfirmedCases[Date]
VAR PrevDay =
CALCULATE(
Min(ConfirmedCases[dates]),
FILTER('ConfirmedCases',
ConfirmedCases[Country/Region]=Countries && ConfirmedCases[Province/State]=State && ConfirmedCases[Date]<dates && ConfirmedCases[New_Cases]=0))
RETURN
PrevDay
Thanks amitchandak! Do I need to create two columns for these?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |