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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
QuentinBl
Helper I
Helper I

Get the average of X last date

Hello everyone, 

I stuck with a DAX query which doesn't seems impossible. 

I try to get the average for the 5 last date available by client. 
In the following exemple, I want average of the last 5 days available by Client 

In the exemple, Client 1 got 6 days. The last 5 are from 9/03/2024 to 20/03/2024. I want the average of those days

QuentinBl_0-1711124242776.png
I end up with this DAX query wich absolutly doesn't work 🙂

AVERAGEX(
    WINDOW(
        -4,REL, 0,REL,
        SUMMARIZE(ALLSELECTED('Table'), 'Table'[Date], 'Table'[Client]),
        ORDERBY('Table'[Date],ASC),
        ,PARTITIONBY('Table'[Client])
    ),
    CALCULATE(SUM('Table'[Valeur]))
)

I need the last date value for my client scope
QuentinBl_0-1711125161836.png

 


Can you help me ?

 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

You're close.

ThxAlot_0-1711175684401.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

You're close.

ThxAlot_0-1711175684401.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Yes. Works perfectly ! Thank you. 

I will analyse why I need a keepfilters here...

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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