Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Weighted Average

Hello,  I need to compute a weighted average for the consumer price.  Currently, CP YTD is computed as Average(DB(consumer price). However, if I use this formula I receive an arithmetic avera...
  • V-lianl-msft's avatar
    5 years ago

    Try to use the sumx function.

    WA = 
    VAR total_ = 
        CALCULATE(
            [NES YTD],
            ALL(xxxxx)
        )
    VAR _Table = 
        ADDCOLUMNS(
            SUMMARIZE(
                Sales,
                xxx[Row1],xxx[Row2]
            ),
            "nes", [NES YTD],
            "cp", [CP YTD]
        )
    RETURN
        SUMX(
            _Table ,
            [cp] * [nes]/total_
        )