Working with the COVID-19 Power BI File trying to make some modifications.
I am looking to create a measure that basically tells me the number of days that daily cases has been going up or down in a row.
If the number of daily cases has gone up 3 days in a row, I would like the measure to return 3. If the number of cases has gone up 10 days in a row I'd like to return 10.
Spent some time trying to search for examples of this, but I couldn't find anything like this in particular.
Go to Solution.
Hi @sublog ,
We can use the following measure to meet your requirement.
VAR t =
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] <= MIN ( 'Table'[Date] ) ),
"dateTotal", SUM ( 'Table'[Total] )
VAR t2 =
VAR d = [Date]
< SUMX ( FILTER ( t, 'Table'[Date] = d - 1 ), [dateTotal] ),
VAR last0dat =
MAXX ( FILTER ( t2, [isDecrease] = 0 ), [Date] )
MAXX ( FILTER ( t2, 'Table'[Date] = MIN ( 'Table'[Date] ) ), [isDecrease] ) = 1,
DATEDIFF ( last0dat, MIN ( 'Table'[Date] ), DAY ),
We can get the result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?
BTW, pbix as attached.
Community Support Team _ zhenbwIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
View solution in original post
For the table below, I would count the consecutive number of days where Test = 1 or 0.
The row for 4/18/2020, the downtrend measure would = 2
The row for 4/17/2020, the downtrend measure would = 1
Learn how to create your own user groups today!
Click here to read more about the October 2021 Release!
Check out the new Power Platform Community Connections gallery!
Mark your calendars and join us for our next Power BI Dev Camp!