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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Problem with dynamic date-filter

I create a monthly report with average-month-values. The table starts in january 1971 and ends with the current month.

 

Now i try to implement a value, which shows the running average from start-date until the current reporting-period (Month).

 

So for example:

 

Date / Value / Average 

1971-Jan / 31 / 31

1971-Feb / 35 / 33

1971-Mar / 36 / 34

...

2023-Feb / 411 / 188

 

I tried it with DATESINPERIOD and with DATESBETWEEN. Unfortunately i have no experience with DAX and it's not so easy to find some help or examples for this examples.

 

{
"name": "AVERAGE_test1",
"expression": "CALCULATE([Value], DATESBETWEEN(Calender[Date], MIN(Date[Datum]), LASTDATE(Calender[Date])))"
}

 

{
"name": "AVERAGE_test2",
"expression": "CALCULATE([Value], DATESINPERIOD(Calender[Date], LASTDATE(Calender[Date]), DATEDIFF(FIRSTDATE(Calender[Date]), LASTDATE(Calender[Date]),MONTH), MONTH))"
}

 

Do I need a COUNTROW-function or something in this way?

 

Thanks for your help! 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1677640605254.png

(2) We can create a measure. 

Average = 
var _a= CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date])))
var _b= CALCULATE(COUNTROWS(FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]))))
return 
DIVIDE(_a,_b,0)

(3) Then the result is as follows.

vtangjiemsft_1-1677640678997.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1677640605254.png

(2) We can create a measure. 

Average = 
var _a= CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date])))
var _b= CALCULATE(COUNTROWS(FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]))))
return 
DIVIDE(_a,_b,0)

(3) Then the result is as follows.

vtangjiemsft_1-1677640678997.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Thank you! 🙂

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.