Forum Discussion

Aditya_Mishra1's avatar
Aditya_Mishra1
Frequent Visitor
2 years ago
Solved

row total Problem for Aging Report

Z_Aging Qty 31-60 = VAR SaleSum= CALCULATE( SUM('Aging Main'[Sold Qty]), FILTER('Aging Main', 'Aging Main'[Date]<=MAX(DateTable[Date])) ) VAR Purch= CALCULATE( SUM('Aging Main'[Purchase...
  • Aditya_Mishra1's avatar
    Aditya_Mishra1
    2 years ago

    Hi Anonymous 

    After applying the DAX you provided, the Total at the bottom is summing up the values of Item group which has been correct so the Total is showing right values, however the values at Product level is still the same after I changed your DAX from Product level to Item level.

     

    Also at last in SUMX function, it's giving error to pass same value as the current measure name.

     

    I modified the DAX you provided to this

    Z_Aging Qty 31-60 Product2 =
    VAR SaleSum =
        CALCULATE(
            SUM('Aging Main'[Sold Qty]),
            FILTER('Aging Main', 'Aging Main'[Date] <= MAX(DateTable[Date]))
        )
    VAR Purch =
        CALCULATE(
            SUM('Aging Main'[Purchase Qty]),
            FILTER('Aging Main', (MAX(DateTable[Date]) - 'Aging Main'[Date]) > 60)
        )
    VAR PurchSum =
        CALCULATE(
            SUM('Aging Main'[Purchase Qty]),
            FILTER('Aging Main', (MAX(DateTable[Date]) - 'Aging Main'[Date]) > 30 && (MAX(DateTable[Date]) - 'Aging Main'[Date]) <= 60)
        )
    VAR Sale = -SaleSum // Sold qty had negative values
    VAR IsItemLevel = HASONEVALUE('Aging Main'[Item Group])
    RETURN
    IF(
        IsItemLevel,
        IF(
            Purch >= Sale,
            IF(ISBLANK(PurchSum), 0, PurchSum),
            VAR SaleSum1 = Sale - Purch
            VAR AgingQty =
                IF(
                    SaleSum1 >= PurchSum,
                    0,
                    IF(ISBLANK(PurchSum - SaleSum1), 0, PurchSum - SaleSum1)
                )
            RETURN AgingQty
        ),
        SUMX(
            VALUES('Aging Main'[Item Group]),
            [Z_Aging Qty 31-60]
        )
    )