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
rmblack92
New Member

If column A Table 1 matches column B Table 2 then return column B table 1

Hi,

 

I'm relatively new to Power BI and need to build a report that shows which suppliers are on contract in order to compare the total spend versus contracted spend as a value & a percentage.

 

Example tables: 

Table 1 

Supplier NumberTotal Spend
A123£98
B123£94
C123£100
D123£88

 

Table 2

Supplier Number
A123
B123
D123

 

What I want to show 

Supplier NumberTotal SpendContracted Spend
A123£98£98
B123£94£94
C123£100 
D123£88£88
Total£380£280

 

Using the sum of each column I will create a Card that shows the percentage of contracted spend so in this example the contract spend would be 73.68%

 

Please help! 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@rmblack92  It looks like you have only some of your suppliers in the DimSupplier table - defined as 'Contracted Spend'. Do you have the non-contracted suppliers in a table somewhere too? It would be handy to have this info in one table. I've created a sample report, but I'm using the SupplierID from the Spend table which is not generally a good idea. 

 

You can create a measure like this; 

Total Spend Contracted =
SUMX(
FILTER(Spend, RELATED( Suppliers_Contracted[Supplier Number]) <> BLANK())
, Spend[Total Spend]
)
 
See attached file below signature. 

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @rmblack92 

BTW, you can use HASONEVALUE() to get the expected result,

vxiaotang_1-1633429330027.png

Contracted Spend = IF(HASONEVALUE(Table1[Supplier Number]),CALCULATE(MIN(Table1[Total Spend (£)]),FILTER(Table1,RELATED(Table2[Supplier Number])<>BLANK())),[Contracted Spend Total])
 

See sample file attached bellow.

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

AllisonKennedy
Super User
Super User

@rmblack92  It looks like you have only some of your suppliers in the DimSupplier table - defined as 'Contracted Spend'. Do you have the non-contracted suppliers in a table somewhere too? It would be handy to have this info in one table. I've created a sample report, but I'm using the SupplierID from the Spend table which is not generally a good idea. 

 

You can create a measure like this; 

Total Spend Contracted =
SUMX(
FILTER(Spend, RELATED( Suppliers_Contracted[Supplier Number]) <> BLANK())
, Spend[Total Spend]
)
 
See attached file below signature. 

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.