Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to sum two thing

Hello expoerts,  I want from example belllow to tell me the dax code that calculate: - the amount orginated from Chaina and imported from Chaina and called the direct &  amount that orginated from ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

    Here are the steps you can follow:

    1. Use Enter data to create a table.

    2. Create measure.

    direct country =
    CALCULATE(SUM('Table'[Amount ]),FILTER(ALL('Table'),'Table'[Country of Origin ]="China"&&'Table'[Country  of Import ]="China"))
    undirect countries =
    CALCULATE(SUM('Table'[Amount ]),FILTER(ALL('Table'),'Table'[Country of Origin ]="China"&&'Table'[Country  of Import ]<>"China"))
    Measure =
    SWITCH(
        TRUE(),
        MAX('Table2'[Group])="direct country",[direct country],
        MAX('Table2'[Group])="undirect countries",[undirect countries])

    3. Result:

     

    Best Regards,

    Liu Yang

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