Forum Discussion

bestevez's avatar
bestevez
Helper I
7 years ago
Solved

DAX problem sum average

Hi,   i have a issue about my dax measure.    SUM( fac_compras[cantidad] ) * CALCULATE(  [avgCosteUnidad]; SAMEPERIODLASTYEAR(dim_date[Date] ) ) all is right, but the total multipli...
  • Stachu's avatar
    Stachu
    6 years ago

    try this

    Measure =
    VAR __Summary =
        ADDCOLUMNS (
            SUMMARIZE ( 'Table', 'Calendar'[YearMonth] ),
            "Quantity CY", CALCULATE ( SUM ( 'Table'[Quantity] ) ),
            "Avg Cost LY", [Average Cost LY]
        )
    RETURN
        SUMX ( __Summary, [Quantity CY] * [Avg Cost LY] )

    the total is alignes with your logic here