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
Necrosis1968
Regular Visitor

Comparing columns error

Hi, sorry first time here and a PowerBI newbie.

I want to compare 2 columns, from different tables in PowerBI. They are joined by Unique-ID. I have tried the following:

Resolved = IF ('report last month'[Unique ID]'report this month'[Unique ID], "No", "Yes")
So basically, if it's in last month's report but not in this one then resolved=No for that row, else it will be Yes. If it's not disappeared from the report it's not resolved.
Problem is I'm getting an error "A single value for column 'Unique ID' in table 'report this month' cannot be determined." 
They are both String variable types.
I did try using MAX function but it sets every row in the resolved column as "Yes". I also tried MIN, but that sets all bar one as "Yes"
Any help appreciated. 
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Necrosis1968 ,

 

According to your statement, I think your error may be caused that you use 'report this month'[Unique ID] directly in your code to create the calculated column.

This error occurs because Power BI is unable to determine which row of data to use in a calculation among multiple rows of data.

Here I create a sample and I can reproduce your issue.

Last Month:

vrzhoumsft_2-1712212945860.png

This Month:

vrzhoumsft_3-1712212956376.png

Error:

vrzhoumsft_0-1712212706602.png

I suggest you to try code as below.

Resolved = IF ('report last month'[Unique ID] in  VALUES('report this month'[Unique ID]), "No", "Yes")

Result is as below.

vrzhoumsft_1-1712212922349.png

 

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Necrosis1968 ,

 

According to your statement, I think your error may be caused that you use 'report this month'[Unique ID] directly in your code to create the calculated column.

This error occurs because Power BI is unable to determine which row of data to use in a calculation among multiple rows of data.

Here I create a sample and I can reproduce your issue.

Last Month:

vrzhoumsft_2-1712212945860.png

This Month:

vrzhoumsft_3-1712212956376.png

Error:

vrzhoumsft_0-1712212706602.png

I suggest you to try code as below.

Resolved = IF ('report last month'[Unique ID] in  VALUES('report this month'[Unique ID]), "No", "Yes")

Result is as below.

vrzhoumsft_1-1712212922349.png

 

Best Regards,
Rico Zhou

 

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

That worked! Thank you so much!

HotChilli
Super User
Super User

You have written a measure (which requires an aggregation). Are the 2 different tables related? This is what powerbi uses to work out the measure.

 

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.

Top Solution Authors