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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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 
ChinaChina34
ChinaUAE3445
UAEUAE5676
ChinaChina6768
ChinaUAE342
UAEKSA132
ChinaUAE323
TurkeyUAE234
ChinaRussia4545
ChinaIndia76
TurkeyTurkey76765
1 ACCEPTED SOLUTION

@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_)) 

 

SU18_powerbi_badge

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.

 

View solution in original post

6 REPLIES 6
AlB
Super User
Super User

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_) 

 

SU18_powerbi_badge

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.

 

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


@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

 

SU18_powerbi_badge

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.

 

Anonymous
Not applicable

I want to show:
1- Card: direct amount

2- Card: Indirect Amount

3- Bar Chart: indirect countries with indirect value 
4- Bar Chart: top commodities for indirect countries  amount
5- Pie Chart: point of entry for for indirect countries  amount

 

 

 

Country of Origin Country  of Import CommodityPoint of EntryAmount 
ChinaChinaMultiple LoudspeakersSarfayt Land Border34
ChinaUAENatural Gas, LiquefiedSOHAR (SEA PORT)3445
UAEUAEBall BearingsAl Wajajah Land Border5676
ChinaChinaElectric DoorbellsCustoms HQ6768
ChinaUAETableware Or KitchenwareHAFEET (BORDER  POST)342
UAEKSAParts Of Gas Turbines, N.E.S.Sarfayt Land Border132
ChinaUAEMultiple LoudspeakersKHATMAT MILAHA (BORDER  POST)323
TurkeyUAESkulcaps (Taqias)Al Darah234
ChinaRussiaAudio-Frequency Electric AmplifiersAl Wajajah Land Border4545
ChinaIndiaDress PatternsSUWEIQ (SEA PORT)76
TurkeyTurkeyInductors, N.E.SAL DUQM (SEA PORT)545
KSAOmanMotors Of An Output <= 37,5 WSARFAIT (BORDER POST)435
KSAKSAMultiple LoudspeakersCENTRAL POST OFFICE150
KSAJapanElectric DoorbellsSalalah International Airport Passenger401
KSAKSANatural Gas, LiquefiedDIBA PORT (BORDER POST)164
KSAIndiaFuel oils For shipsAl Darah191
USAUSAFrozen Cuttle fish and squidDIRECTORATE GENERA393
USABrazilDress PatternsSarfayt Land Border167
USACanadaAudio-Frequency Electric AmplifiersARKAN SOHAR LOGISTICS LLC NORTH307
USAUSASweet Biscuits  HAFEET (BORDER  POST)100
USAUSAHair Lacquers  ARKAN SOHAR LOGISTICS LLC NORTH209
USAEgyptHousehold Ware Of ZincDIBA PORT (BORDER POST)226
USAIraqSweet Biscuits  Sarfayt Land Border484

@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_)) 

 

SU18_powerbi_badge

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.

 

Anonymous
Not applicable

Hello ALB again,
in this photo, I used merged bar chart, and I want to put tooltip that show % of each market for China and non China>>
For Example, Mineral product market , it shows me % of China and % of Non - China by the total value of mineral product market

 

% percentag issue.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors