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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Bambang_Sono
Frequent Visitor

Takes and filters the number of value data then displays the average per day and month

hi Please help, I want to create a filter table to find the average cumulative tonnage by adding up the value data first and then displaying the average cumulative per day and month, here is an example from my image: 🙏

 

help1.png

1 ACCEPTED SOLUTION
miTutorials
Super User
Super User

Try the below code to create a new calculated table to return the Cumulative Avg Value.

 

CUMULATIVE_AVG_TABLE = 
ADDCOLUMNS(
    SUMMARIZE('Table', 'Table'[DATE], 'Table'[MONTH]),
    "SUM TONASE", CALCULATE(SUM('Table'[TONASE])),
    "AVG TONASE",
    VAR CurrentDate = 'Table'[DATE]
    VAR CurrentMonth = 'Table'[MONTH]

    VAR CumulativeTonnage =
        CALCULATE(
            SUM('Table'[TONASE]),
            FILTER(
                'Table',
                'Table'[DATE] <= CurrentDate &&
                'Table'[MONTH] = CurrentMonth
            )
        )

    VAR DaysCount =
        CALCULATE(
            DISTINCTCOUNT('Table'[DATE]),
            FILTER(
                'Table',
                'Table'[DATE] <= CurrentDate &&
                'Table'[MONTH] = CurrentMonth
            )
        )

    RETURN 
        DIVIDE(CumulativeTonnage, DaysCount)
)

View solution in original post

4 REPLIES 4
miTutorials
Super User
Super User

Try the below code to create a new calculated table to return the Cumulative Avg Value.

 

CUMULATIVE_AVG_TABLE = 
ADDCOLUMNS(
    SUMMARIZE('Table', 'Table'[DATE], 'Table'[MONTH]),
    "SUM TONASE", CALCULATE(SUM('Table'[TONASE])),
    "AVG TONASE",
    VAR CurrentDate = 'Table'[DATE]
    VAR CurrentMonth = 'Table'[MONTH]

    VAR CumulativeTonnage =
        CALCULATE(
            SUM('Table'[TONASE]),
            FILTER(
                'Table',
                'Table'[DATE] <= CurrentDate &&
                'Table'[MONTH] = CurrentMonth
            )
        )

    VAR DaysCount =
        CALCULATE(
            DISTINCTCOUNT('Table'[DATE]),
            FILTER(
                'Table',
                'Table'[DATE] <= CurrentDate &&
                'Table'[MONTH] = CurrentMonth
            )
        )

    RETURN 
        DIVIDE(CumulativeTonnage, DaysCount)
)

hi @miTutorials For example how do you measure it?

hi @miTutorials thank solved

 

girishthimmaiah
Resolver I
Resolver I

1. Create a Measure to Calculate Daily Sum of Tonnage
First, you will need to aggregate the weight for each date.

DAX Measure:
DAX
Copy
Daily Sum Tonase =
CALCULATE(
SUM('YourTable'[TONASE]),
ALLEXCEPT('YourTable', 'YourTable'[DATE])
)
2. Create Cumulative Average Measure
And then, you will get a cumulative average measure, calculating the accumulated average of daily tonnage by its accumulated sum divided by the number of days.

DAX Measure for Cumulative Average:
DAX
Copy
Cumulative Avg Tonase =
CALCULATE(
AVERAGEX(
FILTER(
ALLSELECTED('YourTable'),
'YourTable'[DATE] <= MAX('YourTable'[DATE])
),
[Daily Sum Tonase]
),
ALLEXCEPT('YourTable', 'YourTable'[MONTH])
)
Measures Explained:
Daily Sum Tonase: Sums the tonnage for every date to match your image under "SUM VALUE".
Cumulative Avg Tonase: The running (cumulative) average weight for tonnage per day, reset by Month.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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