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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Lucasr46
New Member

Last 7 days AVARAGE

Hello everyone. How it's going?

 

I need to create an avarage of the requests made of the last 7 days.

 

Each line of the table is a request.

Lucasr46_0-1681310679298.png

 

 

The collum "Prazo separacao" is my date.

Lucasr46_1-1681310748450.png

 

 

Please, who can help me?

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Lucasr46 

it depends on the starting point of last 7 days, if you mean Today/Now, try like:

Measure = 
DIVIDE(
    SUMX(
        FILTER(
           Data,
           Data[Date]>NOW()-7&&Data[Date]<=NOW()
        ),
        Data[Qty]
    ),
    7
)
MohammadLoran25
Solution Sage
Solution Sage

Hi @Lucasr46 ,

Use this measure:

 

Measure =
VAR _MAXDATE =
    CALCULATE ( MAX ( RequestTable[Date] ), ALL ( RequestTable ) )
RETURN
    DIVIDE (
        CALCULATE (
            SUM ( RequestTable[Request] ),
            FILTER (
                RequestTable,
                RequestTable[Date] <= _MAXDATE
                    && RequestTable[Date] >= _MAXDATE - 6
            )
        ),
        CALCULATE (
            COUNTROWS ( VALUES ( RequestTable[Date] ) ),
            FILTER (
                RequestTable,
                RequestTable[Date] <= _MAXDATE
                    && RequestTable[Date] >= _MAXDATE - 6
            )
        )
    )

 

If this answer solves your problem, give it a thumbs up and mark it as an accepted solution so the others would find what they need easier.

Regards,
Loran

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors