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 Chain but imported from countries other than Chaina and called undirect counties.

Them tell me what the best chart should to use to show the amount for amount direct country  and undirect countries.

  • 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

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

    • Anonymous's avatar
      Anonymous
      Not applicable
      Country of Origin Country  of Import Amount 
      ChinaChina34
      ChinaUAE3445
      ChinaUAE5676
      ChinaChina6768
      ChinaUAE342
      ChinaKSA132
      ChinaUAE323
      TurkeyUAE234
      ChinaRussia4545
      ChinaIndia76

       

      @dtxtreme

    • Anonymous's avatar
      Anonymous
      Not applicable

      Whitewater100 
      Hello again, 
      I gave you before an example for specific country which is China.
      How I can do that a dynamaic, for example, when I use slicer for any country in country of Origin,  it give direct and undirect values for country of Import

  • Anonymous's avatar
    Anonymous
    Not applicable

     

    try this

    Imp & Org China = calculate(sum(Data[Amount ]),Data[Country of Origin ]="China"&&Data[Country of Import ]="China")
    Origin China-Import Not China = calculate(sum(Data[Amount ]),Data[Country of Origin ]="China"&&Data[Country of Import ]<>"China")
  • Hi:

    These are the calculated columns I sent earlier with the visual examples:

    Direct(org & Imp China) = IF(AND(Data[Country of Origin ] = "China", Data[Country of Import ] = "China"), Data[Amount ])
    Origin China-Import Not China = IF(AND(Data[Country of Origin ] = "China", Data[Country of Import ] <> "China"), Data[Amount ])