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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
elke_hh
New Member

sequence of calculate "max" in aggregation of a "running sum"

Hello Forum,

I have following problem when trying to calculate a "running sum" over a measure which determines a maximum value out of two measures.

The issue is, that I cannot force the determination of the max-value before it comes to the calculation of the sum. The determination of max-Value is correct on its own but in the aggregation of running-sum it looks as if first sum is caculatet and then max-Value.

My query looks like this:

RunningSum_ofMAX =

VAR RunningSum =
        CALCULATE (
           max([MeasureA], [MeasureB]),
                FILTER (
                    ALL ( D_DATETABLE ),
                    D_DATETABLE[Calendar Day] <= MAX ( D_DATETABLE[Calendar Day] )
                )
            )  
RETURN
    RunningSum
 
MeasureA and MeasureB are simple calculations:
calculate(sum(Table[Quantity]),D_DATETABLE[ROLLING 12 M],Filter(ALL(D_MEASURE),D_MEASURE[MEASURE_ID] = 1)))
 
It would be great, to get a hint
Thanks Elke
1 ACCEPTED SOLUTION
elke_hh
New Member

I will resolve my issue as follows:
The measure is used in datecontext "Year-Month" and "Year-Week".
For this I will use a tablefunction with max values of [MeasureA] and [MeasureB] for each "Year-Month" (same for "Year-Week) . This max-Value can be summed up with sumx iteratly in the running sum.
Not the generic solution I would prefer but no longer worth time to spend on

View solution in original post

3 REPLIES 3
elke_hh
New Member

I will resolve my issue as follows:
The measure is used in datecontext "Year-Month" and "Year-Week".
For this I will use a tablefunction with max values of [MeasureA] and [MeasureB] for each "Year-Month" (same for "Year-Week) . This max-Value can be summed up with sumx iteratly in the running sum.
Not the generic solution I would prefer but no longer worth time to spend on

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try something like below.

 

RunningSum_ofMAX =
VAR RunningSum =
    SUMX (
        FILTER (
            ALL ( D_DATETABLE ),
            D_DATETABLE[Calendar Day] <= MAX ( D_DATETABLE[Calendar Day] )
        ),
        CALCULATE ( MAX ( [MeasureA], [MeasureB] ) )
    )
RETURN
    RunningSum

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you Jihwan_Kim.

I tried your query, but the result is running sum of (MeasureA+MeasureB).

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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