Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
12 | |
11 | |
10 | |
9 |