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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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