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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Syndicate_Admin
Administrator
Administrator

Get Average of the last 7 days starting on Tuesday

Good afternoon everyone!

I hope you can help me.

I need PowerBI to show me the average of the last 7 days starting on Tuesday.

From Tuesday the price changes are made.

I could not find any formula that takes me the average of the last 7 days starting from Tuesday

Example

Camilagauna_123_0-1664819385788.png

In return a table or Matrix with a row showing a result

Camilagauna_123_1-1664819428825.png

Search Forums, Internet Videos, I asked for help from other colleagues but couldn't get it.

I hope you will help me,

Best regards!

1 ACCEPTED SOLUTION

After two weeks of trial and error, you finally helped me and I was able to achieve it.

You are a Hero, Thank you very much ! 😁

Last query, because adding a column with an "@" is the only thing I didn't understand

Camilagauna_123_0-1664828525526.png

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

One of ways to achieve this is to create a proper calendar table like the attached pbix file, that DayOfWeek number starts from Tuesday (1) and ends on Monday (7).

I hope the below sample can provide some ideas on how to create a solution for your datamodel.

Jihwan_Kim_1-1664820691553.png

 

 

Jihwan_Kim_0-1664820662661.png

 

Avg last 7 days start from Tue: =
AVERAGEX (
    ADDCOLUMNS (
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[End of Week] = MAX ( 'Calendar'[End of Week] )
                && 'Calendar'[Day of Week] <= MAX ( 'Calendar'[Day of Week] )
        ),
        "@qty", [Qty measure:]
    ),
    [@qty]
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

After two weeks of trial and error, you finally helped me and I was able to achieve it.

You are a Hero, Thank you very much ! 😁

Last query, because adding a column with an "@" is the only thing I didn't understand

Camilagauna_123_0-1664828525526.png

Hi,

Thank you for your feedback.

In the formula, @ has no meaning. It is just my habit that I learned from some other experts. When I try to create a column in a virtual table inside DAX formula, I usually name it with @, and the reason is not to be confused by other existing measures or other existing columns (Other existing measures come with table name, so the main purpose is not to be confused by other exising measures).

I hope this helps.

Thanks.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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