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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Tobias106
Helper I
Helper I

Calculate an repeating average value to create a linear average line

Hi everbody,

 

I have a tableA: Therin I have a Date-column (Date) an 1 column with values (Value).

TableA is connected to a calendar (calendar). In the the calendar I have a measureA to show the date in the x-axis only until the last full calender week.

 

Additonally, I use the filter in the filter panel to exclude dates before 2021.

 

Now my problem:

I want to calculate the average of the column „Value“ from 01.01.2021 till the last full calender week to show a linear line with the average value in the graphic.

 

I tried it with: Average = CALCULATE(AVERAGEX('tableA', 'tableA'[Value]), ALLSELECTED(calendar[measureA]))

 

I get the correct average value as total sum (35), but not for every date. I need the same average value (35) for every date to show the linear average line. And it is important, that my filter (in the filter panel) and my meassure are still active.

 

Any idea?

 

Thank you very much

Tobias

3 REPLIES 3
amitchandak
Super User
Super User

@Tobias106 , It should be like

 

CALCULATE(AVERAGEX('tableA', 'tableA'[Value]), ALLSELECTED(calendar) )

 

or

 

CALCULATE(AVERAGEX(values('Date'[Date]),calculate(sum( 'tableA'[Value])) ), ALLSELECTED(calendar) )

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thank you 🙂

 

Your second measure shows me the same average value (35) for every date, which is very good.

 

But I have a measure (measureA) in the calender, which determines the date until the last calender week. In the Filter panel I excluded additionally - by using measureA in the filter panel - the dates before 2021. 

 

Now, with your solution I have the 35, but I have also all Dates from my calender after the last full calender weak (the filter date < -2021 in the filter panel still works) . Therefore, the measureA ist not any more active if I use "ALLSELECTED(calendar)" at the end.

 

I hope I you can understand what I mean :D. Sincerely, I cannot upload data from company-account. 

 

 

Anonymous
Not applicable

Hi @Tobias106,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.