Forum Discussion
Counting days for a given value without considering previous value
- 5 years ago
Hi, Anonymous
You need to create a index column in query editor firstThen you can try to create calculated columns as below:
color flag = VAR value1 = 'COVID'[TRANSMISSIBILIDADE] RETURN SWITCH ( TRUE (), value1 > 1.5, "red", value1 >= 1 && value1 <= 1.5, "orange", value1 < 1, "green" )ChangedStatue = VAR pre = CALCULATE ( VALUES ( COVID[color flag] ), FILTER ( ALL ( COVID ), 'COVID'[Index] = EARLIER ( COVID[Index] ) - 1 ) ) RETURN IF ( ISBLANK ( pre ) || pre = 'COVID'[color flag],"unchanged","changed" )Counting days = VAR _max = CALCULATE ( MAX ( 'COVID'[Index] ), FILTER ( 'COVID', 'COVID'[Index] <= EARLIER ( 'COVID'[Index] ) && 'COVID'[ChangedStatue] = "changed" ) ) RETURN IF ( ISBLANK ( _max ), 'COVID'[Index], 'COVID'[Index] - _max + 1 )The result will show as below:
For more details,please check the attached file.
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous , it seems more like cumulative
example
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=maxx(date,date[date])))
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(Sales[Sales Date])))
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.