Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
They say a picture says more than 1000 words. Below is what I am hoping to achieve.
Have both Sales and a Constant line representing average in a chart but depending on slicers such as region or selection of Financial Years I would like the average to be calculated and shown as a horizontal line for the period.
Is there any way to achieve this in powerpivot/bi?
My challenge is if I tell it to ignore the row filters representing years then the years modified by slicers will also be ignored so it's a catch of 22.. 😞
Copy of AvguSales:= CALCULATE(AVERAGE('AllActSales_table2'[SALES]),ALLEXCEPT(AllActSales_table,AllActSales_table[Period]))
Any ideas would be greatly appreciated.
Solved! Go to Solution.
Ok here is the solution / workaround that does the job. If there is any better way please let me know:
I created an extra disconnected Calendar table and created slicers for both the disconnected calendar and the connected calendar.
With VBA (busted, yes I work in Excel, my organisation is not ready for PowerBi as of yet) so that only 1 slicer is used I am able to have one slicer control the other, this way the two calendars can remain disconnected.
My 2 Measures are:
FILTER(AllActSales_table,
AllActSales_table[Period] >= MIN(discCalendar[Date]) &&
AllActSales_table[Period] <= MAX(discCalendar[Date])))
ALLEXCEPT('Calendar',Calendar[Date]))
Now depending how the user ajusts the slicers the average (constant horizontal line) for the selected years (and region) will recalibrate:
@sliceNdiceUup
This measure should work for you, please try:
Avg Sales =
CALCULATE(
AVERAGE('AllActSales_table2'[SALES]),
ALLSELECTED(AllActSales_table[Period])
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Fomy
Thanks mate, appreciate that.
Unfortunately with that formula you allow the row filters representing years within the pivot table to work. Please see image below with your formula and my "desired result". I would like to ignore row filters representing years (on the pivot table) but actually don't ignore it when calculating the average over the selected years via the slicers. I know it's a bit of contradicting requirement which is why I am not sure how to workaround it.
Ok here is the solution / workaround that does the job. If there is any better way please let me know:
I created an extra disconnected Calendar table and created slicers for both the disconnected calendar and the connected calendar.
With VBA (busted, yes I work in Excel, my organisation is not ready for PowerBi as of yet) so that only 1 slicer is used I am able to have one slicer control the other, this way the two calendars can remain disconnected.
My 2 Measures are:
FILTER(AllActSales_table,
AllActSales_table[Period] >= MIN(discCalendar[Date]) &&
AllActSales_table[Period] <= MAX(discCalendar[Date])))
ALLEXCEPT('Calendar',Calendar[Date]))
Now depending how the user ajusts the slicers the average (constant horizontal line) for the selected years (and region) will recalibrate:
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |