Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created March 22, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImkeF/35aa4d6ae7d21f076f0f98463d322288 to your computer and use it in GitHub Desktop.
Save ImkeF/35aa4d6ae7d21f076f0f98463d322288 to your computer and use it in GitHub Desktop.
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