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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pra137
Helper III
Helper III

Weekly Shift wise Cummulative sum

Hi Guys,

I have to calculate shiftwise cummulative of weekly data, In my table 1day of week contains 3 shifts i.e in 1 week there are 21 shifts ,
when the new week start cummulative should be start from 1 days and F shift of that Week . i want result like below cummulative column please help 

DateWeekShiftValueCummulative
1-1-20201F-10-10
1-1-20201S-10-20
1-1-20201N0-20
2-1-20201F-10-30
2-1-20201S-10-40
2-1-20201N0-40
6-1-20201N0-40
7-1-20201F10-30
7-1-20201S030
7-1-20201N-10-20
8-1-20202F1010
8-1-20202S1020
8-1-20202N020
 


Thanks,
pra137



1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @pra137 ,

 

Try this:

 

1. Add Index column in Power Query Editor.

index.jpg

 

2. Create a calculated column or measure like so:

Column = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Week] = EARLIER ( 'Table'[Week] )
            && 'Table'[Index] <= EARLIER ( 'Table'[Index] )
    )
)

column.PNG

 

Measure = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        ALLSELECTED( 'Table' ),
        'Table'[Week] = MAX( 'Table'[Week] )
            && 'Table'[Index] <= MAX( 'Table'[Index] )
    )
)

measure.PNG

BTW, .pbix file attached.

 

 

 

Best Regards,

Icey

 

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

3 REPLIES 3
Icey
Community Support
Community Support

Hi @pra137 ,

 

Try this:

 

1. Add Index column in Power Query Editor.

index.jpg

 

2. Create a calculated column or measure like so:

Column = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Week] = EARLIER ( 'Table'[Week] )
            && 'Table'[Index] <= EARLIER ( 'Table'[Index] )
    )
)

column.PNG

 

Measure = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        ALLSELECTED( 'Table' ),
        'Table'[Week] = MAX( 'Table'[Week] )
            && 'Table'[Index] <= MAX( 'Table'[Index] )
    )
)

measure.PNG

BTW, .pbix file attached.

 

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@pra137 , try like

Cumm = CALCULATE(SUM(Table[Value]),filter(all(Table),Table[date] <=max(Table[Date]) && Table[Shift] =max(Table[Shift]) ))

or

Cumm = CALCULATE(SUM(Table[Value]),filter(allselected(Table),Table[date] <=max(Table[Date]) && Table[Shift] =max(Table[Shift]) ))

Hii @amitchandak ,
Thanks for reply but it is not working it gives me output like Cumm column

cumm
-10
-10
0
-20
-20
0

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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