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
coolshib
Helper III
Helper III

Need help to compare two tables using multiple criteria

Hello Everyone,

I have following tables

 

Location: 1
CompanyProductSale
ABCApple100
XXXOrange200
YYYPear300
ZZZBanana400

 

Location: 2
CompanyProductSale
ABCApple300
XXXOrange150
YYYPear200
ZZZBanana450
XYZCherry800
DYBPlum200
ZYXGuava500

 

Now i need to compare product wise company wise total sales of location 1 with location 2.

 

CompanyProductSales Location 1Sales Location 2
ABCApple  
XXXOrange  
YYYPear  
ZZZBanana  

 

Many Thanks in advance.

Best Regards,

Shib

 

 

 

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@coolshib 

Once you have created a relationship between the tables, you could create measure that returns the sales in location 2. 

 

 

Sale location2 = CALCULATE(SUM(Location2[Sale]),
FILTER(Location1,Location1[Product] in VALUES(Location2[Product])),
FILTER(Location1,Location1[Company] in VALUES(Location2[Company])))

 


compares sales.JPGvisual.JPG

 

Paul Zheng

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Create common company and product dimension and join both tables with them . Sales from location 1 is location 1 sales.

 

company = distinct(location1[company])

Or

company = distinct(union(distinct(location1[company]),distinct(location2[company])))

 

Same way create product

 

or create a new table like

union (summarize(location1,location1[company],location1[Product],"Sales Location 1",sum(location1[sales]),"Sales Location 2",0.0),
summarize(location2,location1[company],location2[Product],"Sales Location 1",0.0,"Sales Location 2",sum(location2[sales]))
)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

V-pazhen-msft
Community Support
Community Support

@coolshib 

Once you have created a relationship between the tables, you could create measure that returns the sales in location 2. 

 

 

Sale location2 = CALCULATE(SUM(Location2[Sale]),
FILTER(Location1,Location1[Product] in VALUES(Location2[Product])),
FILTER(Location1,Location1[Company] in VALUES(Location2[Company])))

 


compares sales.JPGvisual.JPG

 

Paul Zheng

Thank you so much @V-pazhen-msft !!!This is exactly what i was looking for.

Many Thanks.

Best Regards,

Shib

 

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.