Forum Discussion

Roseventura's avatar
Roseventura
Icon for Responsive Resident rankResponsive Resident
1 year ago
Solved

Incorrect Totals when adjusting the value based on Year-Mo

Hi all,   I'm having a very common problem but can't get the correct results.  Basically, I need to adjust my credits if the month is the current month.  If it's not the current month, then don't a...
  • hnam_2006's avatar
    1 year ago

    Hi Roseventura 

     

    In DAX, when you use SUMX(VALUES...), the calculation is done row by row... even for totals. thats why you get wrong values.

    Try the following DAX... it should fix your problem

    Credits Less Credit Adjustment =
    SUMX (
        ADDCOLUMNS (
            VALUES ( PBI_FSCAPF[YEAR-MO] ),
            "AdjustedCredit",
                IF (
                    [YEAR-MO] = [Current Year-Mo],
                    -([Selected Sales Adjustment] + [QTD Actual Credit Sales]),
                    [QTD Actual Credit Sales]
                )
        ),
        [AdjustedCredit]
    )

     

    Best Regards,

    hnam_2006

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