Forum Discussion

jeoosma's avatar
jeoosma
Helper II
8 years ago
Solved

calculated field

Hi. I don't know if it is possible make what I want. In a page I have two table which origin is two different table. The two table have some rows and the total. I would create a field that has the difference of the two total. How can I resolve? Thank you.

 

PS: Sory for my english, I'm from Italy.....

  • Anonymous's avatar
    Anonymous
    8 years ago

    jeoosma,


    You screenshot is not clear.

    Please try the DAX below.

    TableDifference = CALCULATE(SUM(CdmEtZKenR[Importo]);ALL(CdmEtZKenR)) - CALCULATE(SUM('CdmEtZKenR(2)'[Importo]);ALL('CdmEtZKenR(2)'))



    Regards,
    Lydia

  • It's probably a filter issue, I can see you're trying to filter on just 2018 on that visual but we have no idea what you're doing on the other visuals, that we're using ALL is going to override it

19 Replies

    • jeoosma's avatar
      jeoosma
      Helper II

      What I would is to create a field with difference between the total 1 and total 2.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion
        TableDifference = CALCULATE([Importo],ALL(Table1)) - CALCULATE([Importo],ALL(Table2))

        Not sure what the table names are for Table1 and Table2 but substitute the right table names.

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    So, the Total line in a table/matrix is whatever calculation is occurring with a filter of ALL. Therefore, you should be able to wrap your calculation in an ALL filter to get the same result that is being shown in your table Total line. Thus, if you want to subtract, you could create a measure like:

     

    TableDifference = CALCULATE([SomeMeasure],ALL(Table1)) - CALCULATE([SomeOtherMeasure],ALL(Table2))