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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cdawidow
Helper III
Helper III

TOTALS INCORRECT WHEN USING MAXX

Hi there, 

 

I just need help calculating dynamic totals within Power BI for the following measure shown below .  Essentially, I am calculating the last recorded Average Cost and QTY On Hand across my 3 branches for a specific product ( TXWHSE) to get my Inventory Value.  But by  using MAXX I know why my totals are based on the MAXX value but my desired output is to SUM the total inventory Values across all 3 of my branches as my total amount.  In this case, it should show $52,455.15 .  How would I go about doing that ? 

 

MAXX1.PNG 

1 REPLY 1
Jos_Woolley
Solution Sage
Solution Sage

Hi,

INVENTORY VALUE =
VAR LASTQ0H =
    CALCULATE (
        MAXX ( INTRAN00, INTRAN00[TXQOH] ),
        LASTDATE ( INTRAN00[TRANSACTION DATE] )
    )
VAR LASTAVGCOST =
    CALCULATE (
        MAXX ( INTRAN00, INTRAN00[NEW AC PER] ),
        LASTDATE ( INTRAN00[TRANSACTION DATE] )
    )
VAR MYTABLE =
    SUMMARIZE (
        INTRAN00,
        INTRAN00[TXWHSE],
        "LastQ0H",
            CALCULATE (
                MAXX ( INTRAN00, INTRAN00[TXQOH] ),
                LASTDATE ( INTRAN00[TRANSACTION DATE] )
            ),
        "LastAvgCost",
            CALCULATE (
                MAXX ( INTRAN00, INTRAN00[NEW AC PER] ),
                LASTDATE ( INTRAN00[TRANSACTION DATE] )
            )
    )
RETURN
    IF (
        HASONEVALUE ( INTRAN00[TXWHSE] ),
        LASTAVGCOST * LASTQ0H,
        SUMX ( MYTABLE, [LastAvgCost] * [LastQ0H] )
    )

Regards

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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