Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
zrouatbi
Frequent Visitor

Calculate average when a Bar is excluded from the chart

Hey Guy,

 

I am new to Power Bi  and I am having a hard time doing something that may be for you is a piece of cake.

 

I have a bar chart where the column value calculates monthly sales and a line value that calculate the average sales for the past 6 months, now when I exclude a bar from the chart by clicking on exclude, the average should dynamically exclude the excluded month and recalculate the average for the past 5 months instead of 6, it this possible?

 

Here is my calculate

 

Rolling = CALCULATE(
(AVERAGEX (values(Finance[Period]), Finance[Sales])),
DATESINPERIOD (
'Finance'[Period],
LASTDATE ( 'Finance'[Period] ),
-6,
MONTH
)
)
2 REPLIES 2
zrouatbi
Frequent Visitor

Hi, @v-easonf-msft ,

 

There is no problem with the formula, I need to make the -6 in my formula dynamic, so when they click on a specific bar on the bar chart and hit exclud, whatever they exclude, should be reflected in the formula.

 

I Belive it is not possible to reference a filter in a formula.

Let me know if I explained this properly.

Thank you very much.

Zied

v-easonf-msft
Community Support
Community Support

Hi, @zrouatbi 

I don't see any problem with the formula you provided.

Please share a sample file to further illustrate your needs.

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.