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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Aazam
Helper I
Helper I

DAX Total is not working

Hi,

I am facing an issue with DAX Total,

Here is my DAX
item cost for max date = var MaxDate = CALCULATE(MAX('Lookup Table'[transaction_date]),ALL('Lookup Table'[transaction_date])) RETURN
CALCULATE(SUMX('Lookup Table','Lookup Table'[Item Cost]),FILTER('Lookup Table','Lookup Table'[transaction_date] = MaxDate))


Aazam_0-1692175375415.png

 

Look at this, It is getting only that value is on MAX date instead of a total of both product



2 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @Aazam 
Please try

item cost for max date =
SUMX (
    SUMMARIZE (
        'Lookup Table',
        'Lookup Table'[Item Code],
        'Lookup Table'[Item Category],
        'Lookup Table'[SKu],
        'Lookup Table'[Location Name]
    ),
    VAR MaxDate =
        CALCULATE (
            MAX ( 'Lookup Table'[transaction_date] ),
            ALL ( 'Lookup Table'[transaction_date] )
        )
    RETURN
        CALCULATE (
            SUMX ( 'Lookup Table', 'Lookup Table'[Item Cost] ),
            KEEPFILTERS ( 'Lookup Table'[transaction_date] = MaxDate )
        )
)

View solution in original post

I resolved it by myself

 

SUMX (
    SUMMARIZE (
        'Lookup Table',
        'INV Sku'[sku],
        'INV Categories'[name],
        'INV Items'[item_code],
        'INV Locations'[location_name]
    ),
    VAR item_cost_for_max_date =
        CALCULATE (
           [item cost for max date]
        )
    VAR item_on_hand =
    CALCULATE(
        [Item_On_Hand_SUM]
    )
    RETURN
       
            item_cost_for_max_date * item_on_hand
       
)

 

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

Hi @Aazam 
Please try

item cost for max date =
SUMX (
    SUMMARIZE (
        'Lookup Table',
        'Lookup Table'[Item Code],
        'Lookup Table'[Item Category],
        'Lookup Table'[SKu],
        'Lookup Table'[Location Name]
    ),
    VAR MaxDate =
        CALCULATE (
            MAX ( 'Lookup Table'[transaction_date] ),
            ALL ( 'Lookup Table'[transaction_date] )
        )
    RETURN
        CALCULATE (
            SUMX ( 'Lookup Table', 'Lookup Table'[Item Cost] ),
            KEEPFILTERS ( 'Lookup Table'[transaction_date] = MaxDate )
        )
)

I have another question related to this,

Total_Cost_Max is the multiplication of item_cost_for_max_date and item_on_hand

Total_Cost_MAX = [item cost for max date] * [Item_On_Hand_SUM]

But in total I want the sum of rows instead of the multiplication of columns.

Aazam_0-1692271816732.png

 



I resolved it by myself

 

SUMX (
    SUMMARIZE (
        'Lookup Table',
        'INV Sku'[sku],
        'INV Categories'[name],
        'INV Items'[item_code],
        'INV Locations'[location_name]
    ),
    VAR item_cost_for_max_date =
        CALCULATE (
           [item cost for max date]
        )
    VAR item_on_hand =
    CALCULATE(
        [Item_On_Hand_SUM]
    )
    RETURN
       
            item_cost_for_max_date * item_on_hand
       
)

 

Thank you for the solution 🙂

Suggest me the learning material for DAXs

eliasayyy
Memorable Member
Memorable Member

not sure why you are using sumx  

item cost for max date = 
var MaxDate = CALCULATE(MAX('Lookup Table'[transaction_date]),ALL('Lookup Table'[transaction_date])) 
RETURN
CALCULATE(SUM('Lookup Table'[Item Cost]),FILTER('Lookup Table','Lookup Table'[transaction_date] = MaxDate))




 

Aazam_0-1692175243165.png

 

Look at this, It is getting only that value is on MAX date instead of a total of both product

try afater the emasure

Total = 
IF(HASONEVALUE([Item Code]),[Item Cost For Max Date] , SUMX(VALUES([Item Code]),[Item Cost For Max Date]))

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.