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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
TaariqHussain
Helper I
Helper I

Percentage difference calculation between two tables

Hi, I have two tables, one with sales and another with costs, I am using the percentage difference measure to calculate the GP% however the GP% is only pulling through for a few products and not for the majority. I was advised to use the related function but not sure how. please see formula below

GP% =
VAR __BASELINE_VALUE = MIN('StockMaster'[Last cost])
VAR __VALUE_TO_COMPARE = MIN('ItemWiseSales'[itemprice])
RETURN
    IF(
        NOT ISBLANK(__VALUE_TO_COMPARE),
        DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE)
    )
 
below is how my visual is appearing.
TaariqHussain_0-1692096372098.png

 

 
1 REPLY 1
amitchandak
Super User
Super User

@TaariqHussain , it ItemWiseSales is master table and on the 1 side in 1 -to-many relation between ItemWiseSales and StockMaster

 

You can create a new column in StockMaster

= related('ItemWiseSales'[itemprice])

 

or measure

Sumx('StockMaster', 'StockMaster'[Last cost] - related('ItemWiseSales'[itemprice]) )

 

other ways

 

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors