Forum Discussion

LeaRupnik's avatar
LeaRupnik
Helper III
5 years ago

exemple sum

Hello, 

 

i have a problem, with sum and thant vhat a have too give in a table in powerBI. 

I have a formula in SSAA:

PLAN NAB PREMIJA VRED:=CALCULATE([SumPlan_nab_premija]*[SumPlan_kol]/1000;
FILTER ( ALL ('cisppr cista_prodajna_premija'); 'cisppr cista_prodajna_premija'[datum_posnetka] = MAX('cisppr cista_prodajna_premija'[datum_posnetka]));
VALUES('cisppr cista_prodajna_premija'[Nivo 1]);
VALUES('cisppr cista_prodajna_premija'[Nivo 2]);
VALUES('cisppr cista_prodajna_premija'[Nivo 3]);
VALUES('cisppr cista_prodajna_premija'[Nivo 4]);
VALUES('cisppr cista_prodajna_premija'[mesec]);
VALUES('cisppr cista_prodajna_premija'[leto])
)

 

than table in PowerBI:

the nivo 4 is ok, nivo 3, nivo 2 and nivo 1 a would like that is sum nivo 3 sum (nivo4) and so one. 

 

Please help. 

 

thx

LEa

 

 

4 Replies

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi LeaRupnik ,

     

    Can you please share some sample data? We will understand your requirement more clearly. Thanks!

     

  • I have a very big data model (data are secure). My question is how to use different formula (measure- DAX) in the same column for different levels.

     

    thx

    Lea

  • This sounds like an order of operations issue. Currently the code is summing the two measures, then doing the multiplication and division and it sounds like you want it to do the multiplication and division first then sum up the results.

     

    You could achieve this by doing a SUMX over the values in [Sistem naziv enote] (assuming that is the lowest level that you want the values calculated at)

     

    eg.

     

    REAL NAB PREMIJA VRED v2 = 
    var maxDatum = MAX('fact (2)'[datum_posnetka])
    return CALCULATE(
        SUMX( VALUES('fact (2)'[Sistem naziv enote]),
        [SumReal_nab_premija]*[REAL NAB KOL]/1000)
            , 'fact (2)'[datum_posnetka] = maxDatum )