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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
szmilosz
New Member

How to sum values for each record belongs ti time interval

Hi there,

 

I would like to sum up the Qty values for each MaterialNumber, grouping them by DateToCalculate + LeadTime (weeks).

I mean summing up all the records with the same MaterialNumber for each record, where their DateToCalculate is less than DateToCalculate + LeadTime (number of weeks).

 

Is it possible to do this in a new column?

I kindly ask for your assistance.

 

szmilosz_0-1692692336330.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @szmilosz ,

 

You can create a measure or a calculated column.

Measure:

Measure =
CALCULATE (
    SUM ( 'Table'[ZEM33.Qty] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [ZEM33.MaterialNumber] = MAX ( 'Table'[ZEM33.MaterialNumber] )
            && [LeadTime] = MAX ( 'Table'[LeadTime] )
            && [DateToCalculate] = MAX ( 'Table'[DateToCalculate] )
    )
)

vstephenmsft_0-1692862866211.png

 

Calculated column:

Column = 
CALCULATE (
    SUM ( 'Table'[ZEM33.Qty] ),
    FILTER (
          'Table' ,
        [ZEM33.MaterialNumber] = EARLIER(  'Table'[ZEM33.MaterialNumber] )
            && [LeadTime] = EARLIER(  'Table'[LeadTime] )
            && [DateToCalculate] = EARLIER(  'Table'[DateToCalculate] )
    )
)

vstephenmsft_1-1692862926857.png

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @szmilosz ,

 

You can create a measure or a calculated column.

Measure:

Measure =
CALCULATE (
    SUM ( 'Table'[ZEM33.Qty] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [ZEM33.MaterialNumber] = MAX ( 'Table'[ZEM33.MaterialNumber] )
            && [LeadTime] = MAX ( 'Table'[LeadTime] )
            && [DateToCalculate] = MAX ( 'Table'[DateToCalculate] )
    )
)

vstephenmsft_0-1692862866211.png

 

Calculated column:

Column = 
CALCULATE (
    SUM ( 'Table'[ZEM33.Qty] ),
    FILTER (
          'Table' ,
        [ZEM33.MaterialNumber] = EARLIER(  'Table'[ZEM33.MaterialNumber] )
            && [LeadTime] = EARLIER(  'Table'[LeadTime] )
            && [DateToCalculate] = EARLIER(  'Table'[DateToCalculate] )
    )
)

vstephenmsft_1-1692862926857.png

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.