Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi, I am fairly new to power BI and have a problem I cannot solve, Ihave searched the boards and can't find a solution.
I would like to display the weekly sales average for a selected period in a matrix visual with the weekending days for the selected period as the columns.
I have a calculated table that return a dynamic date period (essentially last 4, 8, 12 weeks) and filters the Date table, which in turn is directly related to the Sales table.
So I can offer the user the option to view only the last 4, 8, 12 weeks of Sales.
I have a requirement to return a matrix with product code as rows and weekending dates as columns that show total sales, and averages sales for the period selected.
I need a measure that retains the time period filters for the average but removes the calendar filters on the visual so that each week column has the same average sales.
Current attempt (returns the average for the week column - which is the same as the sales value obviously) is:
Currently my Weekly Sales for the Selected Period is Calculated like this:
Sales Period Selected =
VAR MinWeek =
CALCULATE (
MINX (
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Date] = MIN ( 'Time Period Selector'[Date] )
),
'Calendar'[WeekEnding]
),
ALLSELECTED ( 'Time Period Selector' )
)
VAR MaxWeek =
CALCULATE (
MAXX (
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Date] = MAX ( 'Time Period Selector'[Date] )
),
'Calendar'[WeekEnding]
),
ALLSELECTED ( 'Time Period Selector' )
)
VAR FirstForecastWeek =
CALCULATE (
MAXX (
FILTER (
ALLSELECTED ( 'Calendar' ),
'Calendar'[IsFutureDay] = FALSE ()
&& 'Calendar'[IsCompletedWeek] = TRUE ()
),
( 'Calendar'[WeekEnding] )
)
)
RETURN
CALCULATE (
[Sales Switch],
FILTER (
Sales,
Sales[Tax date] > MinWeek
&& Sales[Tax date] <= FirstForecastWeek
)
)
And the weekly average is like this:
Averagy Weekly Sales =
AVERAGEX(
SUMMARIZE(
ALLSELECTED('Calendar'),
'Calendar'[WeekEnding]
),
[Sales Period Selected]
)
Which becasue of the Filter Context in the table gives the same value for the week as the sales (average of weekly sales over 1 week = sum of sales)
If I remove filters like this
AVERAGEX(
SUMMARIZE(
ALLSELECTED('Calendar'),
'Calendar'[WeekEnding]
),
[Sales Period Selected]
),
REMOVEFILTERS('Calendar')
)
I get the right value (So the correct average over the number of weeks in the selected period) BUT... the martix visual then retunrs ALL the weeks in the calendar table
Red weeks NOT in period, Yellow in period
Please help
Solved! Go to Solution.
Solved:
I had to remove the filters from the calendar so that the calculation could be done over the full set of weeks but retain them for time period selected.
Solved:
I had to remove the filters from the calendar so that the calculation could be done over the full set of weeks but retain them for time period selected.
Can anyone help? Do you need more information?
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
19 | |
18 | |
18 | |
15 |
User | Count |
---|---|
38 | |
20 | |
18 | |
16 | |
10 |