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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jcastr02
Post Prodigy
Post Prodigy

Average on or after a specific date

I have a file with store closing dates and daily sales....

I'd like to be able to see the average of the Daily Sales column only for data ON or AFTER the closure date.  Example for store 123, the Average of those 6 Dates is ~297, but for those 5 dates after 1/2/2025, the average is 305 =  (257+300+301+333+332)/ 5

Is there a measure that can do this?

See below sample data

DateStr NumberDaily SalesClosure DateAvg After Closing Date
1/1/20251232561/2/2025 
1/2/20251232571/2/2025305
1/3/20251233001/2/2025 
1/4/20251233011/2/2025 
1/5/20251233331/2/2025 
1/6/20251233321/2/2025 
1/1/20254561001/3/2025 
1/2/20254561011/3/2025 
1/3/20254561251/3/2025113
1/4/20254561101/3/2025 
1/5/20254561111/3/2025 
1/6/20254561051/3/2025 
1/1/20257895011/4/2025 
1/2/20257895251/4/2025 
1/3/20257895651/4/2025 
1/4/20257895251/4/2025529
1/5/20257895301/4/2025 
1/6/20257895311/4/2025 
1/1/20251017001/5/2025 
1/2/20251017051/5/2025 
1/3/20251017021/5/2025 
1/4/20251017011/5/2025 
1/5/20251016941/5/2025687
1/6/20251016801/5/2025 
1/1/20251021001/6/2025 
1/2/20251021081/6/2025 
1/3/20251021071/6/2025 
1/4/20251021061/6/2025 
1/5/20251021051/6/2025 
1/6/20251021151/6/2025115
2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@jcastr02,

 

Try this measure:

 

Avg After Closing Date = 
VAR vTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ),
        'Table'[Date] >= 'Table'[Closure Date]
    )
VAR vResult =
    AVERAGEX ( vTable, 'Table'[Daily Sales] )
RETURN
    vResult

 

DataInsights_0-1733169574813.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@jcastr02,

 

Try adding an additional filter to exclude blank dates:

 

Avg After Closing Date =
VAR vTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ),
        'Table'[Date] >= 'Table'[Closure Date],
        NOT ISBLANK ( 'Table'[Closure Date] )
    )
VAR vResult =
    AVERAGEX ( vTable, 'Table'[Daily Sales] )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

ThxAlot_0-1733169799904.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


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


)



DataInsights
Super User
Super User

@jcastr02,

 

Try this measure:

 

Avg After Closing Date = 
VAR vTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ),
        'Table'[Date] >= 'Table'[Closure Date]
    )
VAR vResult =
    AVERAGEX ( vTable, 'Table'[Daily Sales] )
RETURN
    vResult

 

DataInsights_0-1733169574813.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you @DataInsights 

Would you know also how to exclude dates where the Closure date field is blank.  It seems when there is no closing date listed its pulling those values in.  Thanks for your help. 

@jcastr02,

 

Try adding an additional filter to exclude blank dates:

 

Avg After Closing Date =
VAR vTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ),
        'Table'[Date] >= 'Table'[Closure Date],
        NOT ISBLANK ( 'Table'[Closure Date] )
    )
VAR vResult =
    AVERAGEX ( vTable, 'Table'[Daily Sales] )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.