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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
sudhakar111
Helper IV
Helper IV

Comparing Values between tables

Hello All, I need some help with a requirement. I have 2 tables one is fact table and other is a reference table. The fact table is like the below table.

Rep NamePlaceStateCityDateProductValue   
DaveMarketNew YorkNew York3/1/2021Congelli F0.5   
SteveCenterGeorgiaAtlanta3/1/2021Congelli G1.5   
BillDownTexasAustin3/2/2021Flan2.5   
AlexTownWashingtonSeattle3/3/2021Gelatin2.0   

 

The data needs to be displayed as matrix format. On the matrix, product column values are shown as separate columns, like the attached image.MatrixMatrix

The Product values have to be comapred with a refrence table,which has product and value. If the reference table value is less for a product the value has to be shown in red. The reference table just have product and value columns.Linking both the tables based on product. I tried the related function to compare the values but it doesnt seem to be working.

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @sudhakar111 

 

You may create a measure as below. The pbix file is attached in the end.

Visual Control = 
IF(
    SUM('Fact'[Related])<SUM('Fact'[Value]),
    "red"
)

 

Then you can set conditional format as below.

a1.png

 

Result:

a2.png

 

For further information, please refer to the following document.

Use conditional formatting in tables 

 

Best Regards

Allan

 

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

View solution in original post

8 REPLIES 8
v-alq-msft
Community Support
Community Support

Hi, @sudhakar111 

 

You may create a measure as below. The pbix file is attached in the end.

Visual Control = 
IF(
    SUM('Fact'[Related])<SUM('Fact'[Value]),
    "red"
)

 

Then you can set conditional format as below.

a1.png

 

Result:

a2.png

 

For further information, please refer to the following document.

Use conditional formatting in tables 

 

Best Regards

Allan

 

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

Thanks a lot @v-alq-msft, The solution works perfectly on the same data. Tried to implement it on the original dataset. The related function does not seem to be working. Please find the screenshot attached.

Related.jpg

Hi, @sudhakar111 

 

Please check the following considerations about Related function:

  • The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship.

  • When the RELATED function performs a lookup, it examines all values in the specified table regardless of any filters that may have been applied.

  • The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value.

  • The RELATED function cannot be used to fetch a column across a limited relationship.

 

If it is a measure, the row context doesn't exist. So the error occurs.

 

Best Regards

Allan

 

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

Thanks a lot. The mistake i did was creating the related function on the reference table. When is created the related function on fact table it worked.

sudhakar111
Helper IV
Helper IV

Thank you both, Created a sample file. Here the values on the matrix have to be compared with the reference table values.If the values are greater than the reference table, those values have to be highlighted in red.

 

https://drive.google.com/file/d/1vlo4r-73T7TcohsehGp8jctn9S60bNKS/view?usp=sharing

vanessafvg
Super User
Super User

how are you trying to compare it can you show what you have done and demonstrate what are trying to do, what is yoru expected result?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




amitchandak
Super User
Super User

@sudhakar111 , related or related table can work depending on join type 1-M or M to1

 

refer if this video can helphttps://www.youtube.com/watch?v=Wu1mWxR23jU

 

or

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Created a sample file. Here the values on the matrix have to be compared with the reference table values.If the values are greater than the reference table, those values have to be highlighted in red.

 

https://drive.google.com/file/d/1vlo4r-73T7TcohsehGp8jctn9S60bNKS/view?usp=sharing

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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