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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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

Anonymous
Not applicable

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
Anonymous
Not applicable

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.