web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / StartsWith function in...
Power Apps
Unanswered

StartsWith function invalid with ||

(0) ShareShare
ReportReport
Posted on by 2

20210930_140101.jpg

Hi, I am new to Powerapp and would like to seek help for this. I am trying to search two different columns, Name and Date ,within one search box and be able to filter my inputs by 'Date'. However, I got this error with I use the '||' function. 

Categories:
  • RusselThomas Profile Picture
    4,014 on at

    Hi @Winnietws ,

    It looks like you're missing a close bracket after your second StartsWith() to close off the filter expression?

    SortbyColumns(Filter(StartsWith()||StartsWith() ) ,"column", sortorder)

    Hope this helps,

     

    RT 

  • Winnietws Profile Picture
    2 on at

    20210930_155133.jpg

    Hi RT , I included the closed bracket. I not sure about the error for 'Date'

  • shoog Profile Picture
    2,164 on at

    Are you sure you want to use StartsWith on a date?

    You could use StartsWith(Text(Date), TextSearchBox1_1.Text) to fix the error, but most likely you want to filter on an exact date using Date = DateValue(TextSearchBox1_1.Text)

  • RusselThomas Profile Picture
    4,014 on at

    Hi @Winnietws ,

    I would guess your problem stems from incompatible data types.

    A Date type is not the same as a Text type.  This means, the string of today's date "2021/09/30" and the output of Today() are not equal because one is Text, and the other is a Date. "2021/09/30" = Today() = False.

    Both sides of a comparison must be of the same types - always.

     

    StartsWith() requires a text value to compare with another text value - if the data is stored as a Date type, then you can't use StartsWith() to compare that date to text unless you also convert the date to text first. 

    Conversely, if the data you're comparing a Date type against is a Text type, you would need to convert it to a date type first for the comparison to work - and then you wouldn't use StartsWith() to do the comparison because it only does text comparisons.

     

    Assuming your column is a Date type, you can try this - but quick disclaimer - I haven't tested it and I'm not going to type the whole thing, just insert the first part of your formula where .... is;

    .... StartsWith(' name', TextSearchBox1_1.Text) || Date = DateValue(TextSearchBox1_1.Text)

    You might get a delegation warning using the DateValue function inside a filter, so you can first define it using a With() statement and pass the result in - so your whole function goes inside the With()

    With({convertedDate: DateValue(TextSearchBox1_1.Text)},
    .... StartsWith(' name', TextSearchBox1_1.Text) || Date = convertedDate)
    )

    Note: If users are typing in dates, they could be doing it as dd/mm/yyyy or mm/dd/yyyy or yyyy/mm/dd and so forth - so if you aren't already using a datepicker to select dates, you might want to consider it to avoid validating date formats.

    Hope this helps,

    RT

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard