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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ACC_Entwickler1
Regular Visitor

Problem with comparisson

Hi folks,

 

I want to compare strings from columns from two tables.

If the same string exists in both tables I want to output 1 if not 0.

I created a new column in Table Diti with the function:

 

if [Zusammengefügt] = Timesheet_std[Zusammengefügt2] then 1 else 0

 

The syntax is fine, but I get 0 for all entries even for the ones which exist in both columns.

Which lead me to the concluison, that maybe the linking of my tables (Diti and Timesheet_std), which are connected through the columns Zusammengefügt and Zusammengefügt2 is not working properly. But when I go into the visuals, everything works fine both tables update if I filter them by something, so the connection should work.

Which leads to my concluison, that the power query function I wrote has a mistake in it, which I wasn't able to find.

If anyone can suggest a solution or a diffrent approach to solve this problem - I would be very happy.

Thanks in advance

Philipp

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @ACC_Entwickler1 ,

 

If case-sensitive, try:

= if List.Contains(#"Timesheet_std"[Zusammengefügt2],[Zusammengefügt]) then 1 else 0

Otherwise:

if List.Contains(List.Transform(#"Timesheet_std"[Zusammengefügt2], each Text.Upper(_)), Text.Upper([Zusammengefügt])) then 1 else 0

vcgaomsft_0-1675061923312.png

vcgaomsft_1-1675061985370.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

adudani
Super User
Super User

hi @ACC_Entwickler1 ,

 

if you are comparing strings, ensure they are the same format ( clean, trim and upper might help, else use Comparer.OrdinalIgnoreCase - PowerQuery M | Microsoft Learn for case insensitive comparisons).

 

if this doesn't work,

 

please provide the pbix / same input and output data removing sensitive information if possible.

 

thanks

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.