Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Aggregation and square

Hi, I am trying to aggregate my data and then square, while PBI first squares and then aggregates as follow: Input id1 id2 value sqvalue 1 10 100 10000 1 10 200 40000 1 20 ...
  • v-alq-msft's avatar
    v-alq-msft
    6 years ago

    Hi, Anonymous 

     

    Based on your description, you may create a measure as below. The pbix file is attached in the end.

    Result = 
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[id1],
        'Table'[id2],
        "diff",SUM('Table'[difference ])
    )
    var newtab = 
    ADDCOLUMNS(
        tab,
        "sqdiff",
        POWER([diff],2)
    )
    return
    SUMX(
        newtab,
        [sqdiff]
    )

     

    Result:

     

    Best Regards

    Allan

     

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