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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BIBOB
Frequent Visitor

Compare two columns' values

Hello Power BI Gods!

 

I'm interested in comparing the values of two different columns in the same Table.

 

My desired outcome looks like this

 
 

I would like to compare Allocation Requested with Allocation actual and if the following logic is True I will get store the results as shown in a new column or measure , just as shown here.

desired outcome.PNG

 

 

 

Note: The name of my table is called Task List, I am not sure if the space between task and list plays a huge role in the syntax or not.

 

Basic logic is:

Allocation requested = allocation actual  - Allocation match

Allocation requested < allocation actual - Over allocated

Allocation requested > allocation actual - requested too high

 

 

Currently, the best I can get is this:

BIBOB_0-1614192414421.png

 

 by using the following formula:

 

Allocation =
IF(
SUM('Task List'[Allocation Requested]) > SUM('Task List'[Allocation Actual]),
"Requested too high"
)
 
I'm pretty sure the sum part is one of the main reason it's not working as intended but I can't make any other meaningful changes to the measure without it giving complete bonkers result.

Any input is appreciated, I'd like to start a discussion 🙂

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@BIBOB if these are columns, add the new column using the following expression, based on your expression, looks like these are columns.

 

 

New Column = 
SWITCH ( TRUE(),
Table[Allocation Requested] = Table[Allocation Actual], "Allocation Match",
Table[Allocation Requested] < Table[Allocation Actual], "Over allocated",
"Requested too high"
)

 

 

Check my latest blog post Improve UX: Show Year in Legend When Using Time Intelligence Measures | PeryTUS IT Solutions  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

13 REPLIES 13
gordykenmuir
Regular Visitor

I am trying to determine if a value appears in a column in two different tables...for example

 

Device Names in table one are

ABC123

DEF456

 

Device Name in table two are

ABC123

GHK789

 

So the ABC123 would produce a positive result of some sort, don't really care what

Whereas DEF456 and GHK789 would BOTH produce negative results for investigation.

 

The idea being to create some sort of action table to enable us to understand gaps in our data in various systems where the data should exist.

Hi,

In TableA, write this calculated column formula

Present in TableB = lookupvalue('tableb'[Code],'tableb'[Code],'tablea'[Code])

In TableB, write this calculated column formula

Present in TableA = lookupvalue('tablea'[Code],'tablea'[Code],'tableb'[Code])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Perfect, thanks Ashish

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@BIBOB my apologies, there should be a comma after TRUE(), sorry about that.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@BIBOB if you want this as a measure, just use the same expression, add a new measure, wrap both the columns in SUM and it should work.

 

Check my latest blog post Improve UX: Show Year in Legend When Using Time Intelligence Measures | PeryTUS IT Solutions  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@BIBOB just sent the solution, add as a column. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@BIBOB if these are columns, add the new column using the following expression, based on your expression, looks like these are columns.

 

 

New Column = 
SWITCH ( TRUE(),
Table[Allocation Requested] = Table[Allocation Actual], "Allocation Match",
Table[Allocation Requested] < Table[Allocation Actual], "Over allocated",
"Requested too high"
)

 

 

Check my latest blog post Improve UX: Show Year in Legend When Using Time Intelligence Measures | PeryTUS IT Solutions  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

BIBOB
Frequent Visitor

As per your advice. I managed to do it both as a new column and as measure. I have provided the exact code i used respectively:

Column solution

New Column =
SWITCH ( TRUE(),
'Task List'[Allocation Requested]= 'Task List'[Allocation Actual], "Allocation Match",
'Task List'[Allocation Requested]< 'Task List'[Allocation Actual], "Over allocated",
"Requested too high"
)
 
And this worked as a measure:
 
Allocation =
SWITCH ( TRUE(),
SUM('Task List'[Allocation Requested]) = SUM('Task List'[Allocation Actual]), "Allocation Match",
SUM('Task List'[Allocation Requested]) < SUM('Task List'[Allocation Actual]), "Over allocated",
"Requested too high"
)
BIBOB
Frequent Visitor

I've tried your formula, but to no avail..

 

I get 

 

Problem 2.pngProblem.png

parry2k
Super User
Super User

@BIBOB allocation request and allocation actual, are these columns or measure?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

BIBOB
Frequent Visitor

Those are columns, my idea is to create a table in my report which show the values from those two column and include a third clumn in that table, which will show whether there is an allocation match, over allocation or requested too high. Just like the second screen shot in the post (allocation is a measure there).

BIBOB
Frequent Visitor

Has anyone else had any similar experiences ?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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