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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
roelf
Helper II
Helper II

Cumulative per day per person

Hi

 

My dashboard is to measure the production of KG's packed, per person, per day in a factory.

 

My data looks like this:

DatePersonReal Weight
01-Jan-22Person A1
01-Jan-22Person A1.5
01-Jan-22Person A1
01-Jan-22Person A1.6
01-Jan-22Person A1
01-Jan-22Person B3.5
01-Jan-22Person B3
01-Jan-22Person B1.5
01-Jan-22Person B2
02-Jan-22Person A1.5
02-Jan-22Person A1
02-Jan-22Person A1
02-Jan-22Person A0.5
02-Jan-22Person B1
02-Jan-22Person B2

 

I Need to get it as follows:

 

DatePersonReal WeightCumulative Weight
01-Jan-22Person A11
01-Jan-22Person A1.52.5
01-Jan-22Person A13.5
01-Jan-22Person A1.65.1
01-Jan-22Person A16.1
01-Jan-22Person B3.53.5
01-Jan-22Person B36.5
01-Jan-22Person B1.58
01-Jan-22Person B210
02-Jan-22Person A1.51.5
02-Jan-22Person A12.5
02-Jan-22Person A13.5
02-Jan-22Person A0.54
02-Jan-22Person B11
02-Jan-22Person B23

 

I then have a futher requirement, where I need to know how much was below and how much over 4 KG.

 

So my table needs to expand to this

DatePersonReal WeightCumulative WeightBelow 4Above 4
01-Jan-22Person A111 
01-Jan-22Person A1.52.51.5 
01-Jan-22Person A13.51 
01-Jan-22Person A1.65.10.51.1
01-Jan-22Person A16.1 1
01-Jan-22Person B3.53.53.5 
01-Jan-22Person B36.50.52.5
01-Jan-22Person B1.58 1.5
01-Jan-22Person B210 2
02-Jan-22Person A1.51.51.5 
02-Jan-22Person A12.51 
02-Jan-22Person A13.51 
02-Jan-22Person A0.540.5 
02-Jan-22Person B111 
02-Jan-22Person B232 

 

I have tried about 5 different ways that I could see on the forum, so thanks to those who's answered a similar problem. I have however not found one that gives me the answer I require.

 

If any of you can assist, it will be much appreciated !

 

Thanks

Roelf

 

 

 

 

 

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

Hi @roelf ,

According to your description, here's my solution.

Add an index column in Power Query, then create three calculated columns.

Cumulative Weight =
SUMX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
            && 'Table'[Person] = EARLIER ( 'Table'[Person] )
            && 'Table'[Index] <= EARLIER ( 'Table'[Index] )
    ),
    'Table'[Real Weight]
)
Above 4 =
VAR _Cum =
    MAXX (
        FILTER (
            'Table',
            'Table'[Date] = EARLIER ( 'Table'[Date] )
                && 'Table'[Person] = EARLIER ( 'Table'[Person] )
                && 'Table'[Cumulative Weight] > 4
                && 'Table'[Cumulative Weight] < EARLIER ( 'Table'[Cumulative Weight] )
        ),
        'Table'[Cumulative Weight]
    )
RETURN
    IF (
        [Cumulative Weight] > 4,
        [Cumulative Weight]
            - IF ( _Cum = BLANK (), 4, _Cum )
    )
Below 4 =
IF (
    [Cumulative Weight] < 4,
    'Table'[Real Weight],
    IF (
        'Table'[Real Weight] - 'Table'[Above 4] = 0,
        BLANK (),
        'Table'[Real Weight] - 'Table'[Above 4]
    )
)

Get the correct result.

vkalyjmsft_0-1666251521450.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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
roelf
Helper II
Helper II

Thank you all for your suggestions - they all worked 100%

What I ended up using:

- Sorted the data in the Power Query

- Then added an index

- Then used the formula given to get the cumulative amount

I have also checked out other examples which suggesting using "RANKX" as a method instead of adding an index column - not sure which is better. I personally preferred adding an index in the query so that I am sure all rows have values.

 

Thanks again all - much appreciated !!

v-yanjiang-msft
Community Support
Community Support

Hi @roelf ,

According to your description, here's my solution.

Add an index column in Power Query, then create three calculated columns.

Cumulative Weight =
SUMX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
            && 'Table'[Person] = EARLIER ( 'Table'[Person] )
            && 'Table'[Index] <= EARLIER ( 'Table'[Index] )
    ),
    'Table'[Real Weight]
)
Above 4 =
VAR _Cum =
    MAXX (
        FILTER (
            'Table',
            'Table'[Date] = EARLIER ( 'Table'[Date] )
                && 'Table'[Person] = EARLIER ( 'Table'[Person] )
                && 'Table'[Cumulative Weight] > 4
                && 'Table'[Cumulative Weight] < EARLIER ( 'Table'[Cumulative Weight] )
        ),
        'Table'[Cumulative Weight]
    )
RETURN
    IF (
        [Cumulative Weight] > 4,
        [Cumulative Weight]
            - IF ( _Cum = BLANK (), 4, _Cum )
    )
Below 4 =
IF (
    [Cumulative Weight] < 4,
    'Table'[Real Weight],
    IF (
        'Table'[Real Weight] - 'Table'[Above 4] = 0,
        BLANK (),
        'Table'[Real Weight] - 'Table'[Above 4]
    )
)

Get the correct result.

vkalyjmsft_0-1666251521450.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

truptis
Community Champion
Community Champion

Hi @roelf ,

For cumulative weight try this:

Result= SUMX (

    FILTER (

        ALLSELECTED ( tablename[Date] ),

        Tablename[Date] <= MAX ( tablename[Date] )

    ),

    [Realweight]

)

 

@roelf -> please hit the thumbs up & mark it as a solution if it helps you. Thanks.

amitchandak
Super User
Super User

@roelf , Add an index column in power query  first and then try a new column

 

cumm  = sumx(filter(Table, [Person] = earlier([Person]) && [Index] <= earlier([index]) ), [Weight])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.