cancel
Showing results for
Did you mean:
Resolver I

## Compare values from two strings

SHi guys,

I have 2 strings in my flow:

String 1

["2022-03-15","2022-03-31","2022-05-10","2022-05-30"]

String 2

["2022-03-26","2022-03-27","2022-03-28","2022-03-29","2022-03-30","2022-03-31"]

Is there a way to compare both Strings and find out if there is any date on both strings?

(In this case 2022-03-31)

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Solution Sage

You can split the strings by the comma, then intersect both arrays to get the strings they have in common

``intersection(split('"2022-03-15","2022-03-31","2022-05-10","2022-05-30"',','),split('"2022-03-26","2022-03-27","2022-03-28","2022-03-29","2022-03-30","2022-03-31"',','))``

will return "2022-03-31"

4 REPLIES 4
Solution Sage

You can split the strings by the comma, then intersect both arrays to get the strings they have in common

``intersection(split('"2022-03-15","2022-03-31","2022-05-10","2022-05-30"',','),split('"2022-03-26","2022-03-27","2022-03-28","2022-03-29","2022-03-30","2022-03-31"',','))``

will return "2022-03-31"

Resolver I

Thanks @KvB1  it works that way.

Although I want to use with variables, and it doesnt work.

Expression: intersection(split(variables('st1'),','),split(variables('st2'),','))

It doesnt return me anything

Solution Sage

This is most likely because of the [ ] that you used to enclose the string. You don't need to do this when initializing the variable.

Because the only date in common is the last one in the second string but not in the first one, it is comparing "2022-03-31"]  to  "2022-03-31"  which obviously doesn't match

Resolver I

Got it!

Just removed the [" and it works.

Announcements

#### Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.