I am trying to create a moving average measure that gives me the moving average per month. My data has weekday as lowest level; however for this specific measure (and visual) I do not want the weekdays to have an impact.
First I created a per month measure:
A per month = DIVIDE([Unique count Z], [Unique count Y]) * 12)
My Unique count Z/Y are defined as follows:
COUNTROWS(DISTINCT(FCT_form[key1]))
The measure that I created for the moving average:
A moving average =
VAR __SELECTED_YEAR = SELECTEDVALUE('Datum'[Jaar])
VAR __SELECTED_MONTH = SELECTEDVALUE('Datum'[Maandnummer])
VAR __SELECTED_DATE = EOMONTH(DATE(__SELECTED_YEAR, __SELECTED_MONTH, 1),
0) -- last day selected month
VAR __START_DATE = DATE(__SELECTED_YEAR - 1, __SELECTED_MONTH + 1,
1) -- first day of selected month a year previous
RETURN
AVERAGEX(
FILTER(
ALL('Datum'),
'Datum'[Datum en] >= __START_DATE && 'Datum'[Datum EN] <= __SELECTED_DATE
),
[A per month])
The problem that I am now facing is that the moving average is calculated using the information on weekday level. So the Unique count Z is the unique count for a specific day and not for the whole month, resuling in a really low number which then again results in really low numbers for the moving average. (for example, the moving averages should range between 1.4 and 1.8 but now show 0.05) The unique count Y is calculated per month, so this measure does not give any trouble.
Things I tried:
- Use the REMOVEFILTERS(), this works for the A per month result. When using this I do get the unique count for Z for the entire month, and no longer for every specific day. However, this does not translate to the moving average.
- Visual calculations, this works when I want to display the moving average in a line graph and not having a month selected. When I select 1 month, it shows the average for that selected month.
The desired end result should be a moving average that i can display on a card visual as well as a line graph.
Sorry if I miss anything in my explenation; please let me know if I can provide anything else.