Forum Discussion

Sam-Ke's avatar
Sam-Ke
New Member
9 months ago
Solved

Calculate Max volumes at Week level

Hello Everyone,   I am sure similar question was already answered, but i might not have the correct way to formulate my research to find it ğŸ˜…   I want to calculate the maximum amount of volumes ...
  • Ahmed-Elfeel's avatar
    9 months ago

    Hi Sam-Ke,

    Try one of these solutions :

     

    First One : Create Weekly Aggregated Measures First

    Factory Past Deliveries Weekly = 
    CALCULATE(
        [Factory Past Deliveries],
        ALLEXCEPT('Calendar', 'Calendar'[WeekNum])
    )
    
    Replenishment Plan Factory Weekly = 
    CALCULATE(
        [Replenishment Plan Factory],
        ALLEXCEPT('Calendar', 'Calendar'[WeekNum])
    )
    
    Max Replenishment / SP =
    MAXX(
        VALUES('Calendar'[WeekNum]),
        MAX([Factory Past Deliveries Weekly], [Replenishment Plan Factory Weekly])
    )

     

    Second Approach: Direct with SUMMARIZE

    Max Replenishment / SP =
    MAXX(
        SUMMARIZE(
            'Calendar',
            'Calendar'[WeekNum],
            "WeeklyMax",
            MAX(
                CALCULATE([Factory Past Deliveries], ALLEXCEPT('Calendar', 'Calendar'[WeekNum])),
                CALCULATE([Replenishment Plan Factory], ALLEXCEPT('Calendar', 'Calendar'[WeekNum]))
            )
        ),
        [WeeklyMax]
    )

     

    Third Approach: with ADDCOLUMNS

    Max Replenishment / SP =
    MAXX(
        ADDCOLUMNS(
            VALUES('Calendar'[WeekNum]),
            "WeeklyValue",
            VAR PastDeliveries = CALCULATE([Factory Past Deliveries], ALLEXCEPT('Calendar', 'Calendar'[WeekNum]))
            VAR Replenishment = CALCULATE([Replenishment Plan Factory], ALLEXCEPT('Calendar', 'Calendar'[WeekNum]))
            RETURN
                MAX(PastDeliveries, Replenishment)
        ),
        [WeeklyValue]
    )

     

    Bonus Tip : 

    If you are using this for setting the Y axis maximum in a visual you might want to add a buffer:

    Max Replenishment / SP for Axis =
    [Max Replenishment / SP] * 1.1  // Adds 10% buffer for better visualization

     

    if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.