Reply
Bambang_Sono
Frequent Visitor
Partially syndicated - Outbound

Cumulative average per day in power bi

Please ask, I want to make a table to find the cumulative average tonnage based on date and month in Power BI, like the following picture:

and this is the dax formula I can't get:
Release Average = CALCULATE(
AVERAGE(DataRelease[TONAGE]),
DataRelease[Date] = EARLIER(DataRelease[Date]))

 

help.png

 

1 ACCEPTED SOLUTION
v-heq-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Bambang_Sono ,
Thanks for ryan_mayu and bhanu_gautam reply.

You can also try the follwing code to create a calculate column

Avg per days = 
VAR CurrentDate = 'Table'[Date]
VAR CurrentMonth = 'Table'[Month]
VAR CurrentTonase = 'Table'[Tonase]
VAR DaysUntilCurrentDate = COUNTROWS(FILTER('Table', 'Table'[Month] = CurrentMonth && 'Table'[Date] <= CurrentDate))
VAR CumulativeTonase = 
    CALCULATE(
        SUM('Table'[Tonase]),
        FILTER(
            'Table',
            'Table'[Month] = CurrentMonth &&
            'Table'[Date] <= CurrentDate
        )
    )
RETURN
    CumulativeTonase / DaysUntilCurrentDate

Final output

vheqmsft_0-1739327054090.png

 

Best regards,
Albert He


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

4 REPLIES 4
v-heq-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Bambang_Sono ,
Thanks for ryan_mayu and bhanu_gautam reply.

You can also try the follwing code to create a calculate column

Avg per days = 
VAR CurrentDate = 'Table'[Date]
VAR CurrentMonth = 'Table'[Month]
VAR CurrentTonase = 'Table'[Tonase]
VAR DaysUntilCurrentDate = COUNTROWS(FILTER('Table', 'Table'[Month] = CurrentMonth && 'Table'[Date] <= CurrentDate))
VAR CumulativeTonase = 
    CALCULATE(
        SUM('Table'[Tonase]),
        FILTER(
            'Table',
            'Table'[Month] = CurrentMonth &&
            'Table'[Date] <= CurrentDate
        )
    )
RETURN
    CumulativeTonase / DaysUntilCurrentDate

Final output

vheqmsft_0-1739327054090.png

 

Best regards,
Albert He


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

 

ryan_mayu
Super User
Super User

Syndicated - Outbound

@Bambang_Sono 

you can try this

 

Column = AVERAGEX(FILTER('Table','Table'[Month]=EARLIER('Table'[Month])&&'Table'[Date]<=EARLIER('Table'[Date])),'Table'[Tonase])

 

11.PNG

pls see the attachment below





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

Proud to be a Super User!




bhanu_gautam
Super User
Super User

Syndicated - Outbound

@Bambang_Sono , Try using

 

DAX
Release Average =
VAR CurrentDate = DataRelease[Date]
RETURN
CALCULATE(
AVERAGE(DataRelease[TONAGE]),
FILTER(
ALL(DataRelease),
DataRelease[Date] <= CurrentDate
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Syndicated - Outbound

What if it's combined with the summarize function?

example of my dax formula:
Average Release =
VAR CurrentDate = DataRelease[Date].[Date]
RETURN
CALCULATE(
AVERAGEX(DataRelease[TONAGE]),
SUMMARIZE(
FILTER(
ALL(DataRelease),DataRelease[Date].[Date] <= CurrentDate)
)

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

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)