Forum Discussion

RobertaCC's avatar
RobertaCC
Frequent Visitor
2 years ago
Solved

measure aggregation "other"

Hi everybody!

I need to create a table (and then graphs) that show the selected products and all the other products aggregated under the common voice "others". I tried the script attached below, but to the voice "other" show the sales amount equal to the sum of the selected products. Can you help me?

 

sales =
var salesofall = calculate(sum('__FINALE POWER BI'[Venduto (siti)]),ALL('__FINALE POWER BI'[Naming in Fattura]))
return
if (ISINSCOPE('Product Names'[Naming in Fattura]),
    var isotherselected = SELECTEDVALUE('Product Names'[Naming in Fattura])="Others"
    var productwithsales =
        ADDCOLUMNS(all('Product Names'[Naming in Fattura]),"amount", calculate(sumx('__FINALE POWER BI','__FINALE POWER BI'[Venduto (siti)])))
    var venduto = calculate(sumx(productwithsales,[amount]),all('Product Names'[Naming in Fattura]))
    var result = if (isotherselected,salesofall-venduto, sumx('__FINALE POWER BI','__FINALE POWER BI'[Venduto (siti)]))
    return result, salesofall)