Forum Discussion
Calculate Direct& undirect Amount
Hello Expers,
I want a help for writing DAX code that caluculat Direct and Undirect Amount as Dynamic by choosing any country in country of Origin slicer.
How?
- Direct Amount is: If I chooses China as A country of Origin in slicer, It give amount when Counry of Origin and country of Imports are China.
- Undirect: give amount when Counry of Origin is China and country of Imports is NOT China.
I gave you an Example for China, But I want a Dynamic for all countries in country of Origin based what I will choose in Country of Origin Slicer.
Thanks in Advanced.
| Country of Origin | Country of Import | Amount |
| China | China | 34 |
| China | UAE | 3445 |
| UAE | UAE | 5676 |
| China | China | 6768 |
| China | UAE | 342 |
| UAE | KSA | 132 |
| China | UAE | 323 |
| Turkey | UAE | 234 |
| China | Russia | 4545 |
| China | India | 76 |
| Turkey | Turkey | 76765 |
Anonymous
Not sure I've understood the requirements correctly but see the attached file for a possible solution. Note the [IndirectAmount] measure has changed slightly:
IndirectAmount = VAR origin_ = SELECTEDVALUE(Table1[Country of Origin]) RETURN CALCULATE(SUM(Table1[Amount]),KEEPFILTERS(Table1[Country of Import] <> origin_))Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
6 Replies
- AlB
Community Champion
Hi Anonymous
Create these two measures and place them in card visuals. See it all at work in the attached file.
DirectAmount = VAR origin_ = SELECTEDVALUE(Table1[Country of Origin]) RETURN CALCULATE(SUM(Table1[Amount]),Table1[Country of Import] = origin_)IndirectAmount = VAR origin_ = SELECTEDVALUE(Table1[Country of Origin]) RETURN CALCULATE(SUM(Table1[Amount]),Table1[Country of Import] <> origin_)Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
- AnonymousNot applicable
Thanks in Advanced.
It worked correctly,
but If I want to show the indirect countries in bar chart?
Also, I have commodities column, then also I want to show top 5 commodites for indirect value for indirect countries.
I hope you understand me😅- AlB
Community Champion
Anonymous wrote:
I hope you understand me😅I don't. Please show a sample of the data with all the columns involed ( I don't see commodities above) and explain further what the chart would show
Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.