Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created March 22, 2020 08:55
Embed
What would you like to do?
DoublingTime =
VAR CurrentDay =
MAX(DailyData[Date] )
// Get half of todays value
VAR ThresholdValue =
CALCULATE(MAX ( DailyData[Confirmed] ), DailyData[Date] = CurrentDay ) / 2
// Get the day when the number of cases was half as much as today
// FILTER returns dates at which the total sum of confirmed cases was below the threshold
VAR DayOfHalf =
CALCULATE (
MAX ( DailyData[Date] ),
FILTER (
ADDCOLUMNS (
SUMMARIZE ( ALL ( DailyData ), 'Date'[Date] ),
"Amount", CALCULATE ( SUM ( DailyData[Confirmed] ) )
),
[Amount] <= ThresholdValue
)
)
VAR DoublingTime = ( CurrentDay - DayOfHalf ) * 1
// Select only meaningful values
VAR Result =
IF ( AND ( DoublingTime < 10000, DoublingTime > 0), DoublingTime )
RETURN
Result
// For details see this blogpost: https://wp.me/p6lgsG-2g8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment