Hi All, (funny I came here for an average per month of a sum - which is elluding me)...
However I deal with dates and odd data a lot, supprised you guys are having an issue...
So a percentage is numerator/denominator (then click on the % in your column tools) easy enough... but over time can be an issue. So lets say you create a simple % measure, but wan tot look at it over time. (say Month to date, last month and year to date).
1) in your hospital data duplicate your date column and make sure its set as "date" in formatting
2) if you dont have a date table click on modelling 'New Table' and paste this in:
Date =
GENERATE (
CALENDAR( DATE( YEAR( TODAY() ) - 4, MONTH( TODAY() ), DAY( TODAY()) ), TODAY()),
VAR startOfWeek = 1 // Where 1 is Sunday and 7 is Saturday, thus a 3 would be Tuesday
VAR currentDay = [Date]
VAR days = DAY( currentDay )
VAR months = MONTH ( currentDay )
VAR years = YEAR ( currentDay )
VAR nowYear = YEAR( TODAY() )
VAR nowMonth = MONTH( TODAY() )
VAR dayIndex = DATEDIFF( currentDay, TODAY(), DAY) * -1
VAR todayNum = WEEKDAY( TODAY() )
VAR weekIndex = INT( ROUNDDOWN( ( dayIndex + -1 * IF( todayNum + startOfWeek <= 6, todayNum + startOfWeek, todayNum + startOfWeek - 7 )) / 7, 0 ) )
RETURN ROW (
"day", days,
"month", months,
"year", years,
"day index", dayIndex,
"week index", weekIndex,
"month index", INT( (years - nowYear ) * 12 + months - nowMonth ),
"year index", INT( years - nowYear )
)
)
3) Link your new date table to your hospital data's duplicate 'date' column in your data (easy this way trust me)
4) Now create a new % measure (say "HAC_CSV_Data[% of HAC's]" and using this create 3 new date range measures:
% of HAC's (MTD) = CALCULATE(HAC_CSV_Data[% of HAC's], DATESMTD('Date'[Date]))
% of HAC's (Prev MTD) = CALCULATE(HAC_CSV_Data[% of HAC's], PREVIOUSMONTH(DATESMTD('Date'[Date])))
% of HAC's (YTD) = TOTALYTD(CALCULATE(HAC_CSV_Data[% of HAC's]),'Date'[Date])
5) once those are created you will need to click on the column tools for each one and format them as %
6) Using the Date table you created and linked to your data - add the Year and Month (only) as a hierarchy into a table visualization, and then add your new 3 measures, just to check they work.
For graphs/charts that flow over years I use the MTD measure the most, not the YTD, as it just works best.
The 3 measures work great in cards btw - flawlessly! (for me) and to do date selections for the end user I add a "Chiclet" into PBi from the free apps and have one for year, and one for month. (or create a new date column = format as dd/mm/yyyy - and to sort, which is a nightmare, create another column formatted as mm/yyyy - and sort using that.) Chiclet works best for me due to the sheer amount of filtering I use in measures, but only if I use the MTD, Prev MTD and YTD cards, otherwise a normal date slicer is fine...
PS - I work with Hospital data all day every day - so this should be easy stuff (wait till you get to title changes and chart x axis changes by selection 🙂
Regards
Andrew