Forum Discussion

LeahZhang's avatar
LeahZhang
Microsoft Employee
4 years ago
Solved

SUMX Calculation

 

Dear Team, 

 

Thanks for your prompt and continious support.

I am fresh new to DAX, and seek team advise on the below mismatch:

 

Two Measure Are:

totalScore #1 =
SUMX ( VALUES ( 'Config -1'[Emission Factor]),'Key Measure'[Emission Factor]*'Key Measure'[Input])
 
totalScore #2 =
SUMX ( VALUES ( 'Config-1Data'[真实历史数据.Plant]),'Key Measure'[Emission Factor]*'Key Measure'[Input])
 
CO2 is a calculation column:
CO2 = 'Config-1Data'[真实历史数据.Input Data] * 'Config-1Data'[Emission Factor]
 
but the value in {Total} are mismatch. Hope team can support to figure it out. Thanks in advance.

 

 

 

  • Try:

    totalscore =
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( Table, Table[GHG item], Table[Plant] ),
            "TScore", [Emission Factor] * [Input]
        ),
        [Tscore]
    )
    

2 Replies

  • LeahZhang , Ideally multiplcation should happen at rows level like column or measure like

     

    new column = [A]* [B]

    new measure = sumx(Table, [A]*[B])

     

    If we need to multiply two measures, not from the same table then you should most granular level using values or summarize(more than one column)

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    Try:

    totalscore =
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( Table, Table[GHG item], Table[Plant] ),
            "TScore", [Emission Factor] * [Input]
        ),
        [Tscore]
    )