Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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.

Screenshot 2022-05-28 172947.png

2 ACCEPTED SOLUTIONS
Whitewater100
Solution Sage
Solution Sage

v-yangliu-msft
Community Support
Community Support

Hi @Anonymous ,

Here are the steps you can follow:

1. Use Enter data to create a table.

vyangliumsft_0-1653980735742.png

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:

vyangliumsft_1-1653980735746.png

 

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

View solution in original post

7 REPLIES 7
v-yangliu-msft
Community Support
Community Support

Hi @Anonymous ,

Here are the steps you can follow:

1. Use Enter data to create a table.

vyangliumsft_0-1653980735742.png

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:

vyangliumsft_1-1653980735746.png

 

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

Whitewater100
Solution Sage
Solution Sage

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 ])
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")
Whitewater100
Solution Sage
Solution Sage

Hello:

Please find report for you. I hope you mark as solution.

https://drive.google.com/file/d/1P8HqbFn_JnOfwBK8k2LxwmafGbMdhfTk/view?usp=sharing 

 

Whitewater100_0-1653763757072.png

 

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

daXtreme
Solution Sage
Solution Sage

An example of such calculations please.

Anonymous
Not applicable

Country of Origin Country  of Import Amount 
ChinaChina34
ChinaUAE3445
ChinaUAE5676
ChinaChina6768
ChinaUAE342
ChinaKSA132
ChinaUAE323
TurkeyUAE234
ChinaRussia4545
ChinaIndia76

 

@dtxtreme

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors