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 Automate / If always returns null
Power Automate
Unanswered

If always returns null

(0) ShareShare
ReportReport
Posted on by

I have a flow pulling sharepoint data and the if-empty always returns null, even when there is a value. What am I doing wrong? 

 

 

if(empty(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time']),null,formatDateTime(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time'],'yyyy-MM-dd HH:mm:ss'))

 

Categories:
I have the same question (0)
  • Srini007 Profile Picture
    3,479 Super User 2026 Season 1 on at

    Hi @Rex2025 

     

    You can try as below

     

    if(isNull(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time']), null, formatDateTime(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time'],'yyyy-MM-dd HH:mm:ss'))

     

    Also make sure that the Closed Time field is of Correct data type(DateTime) in your Sharepoint list. 

     

    Hope this may help you

     

    Thanks,

    Srini

  • Rex2025 Profile Picture
    on at

    I get this error with that formula: 

     

    Unable to process template language expressions in action 'Compose_-_Sharepoint_Data' inputs at line '0' and column '0': 'The template function 'isNull' is not defined or not valid.'.

  • Srini007 Profile Picture
    3,479 Super User 2026 Season 1 on at

    Hi @Rex2025 

     

    Apologies for the error, try below?

     

    if(empty(trim(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time'])), null, formatDateTime(items('Apply_to_each_-_Sharepoint_Data')?['Closed Time'],'yyyy-MM-dd HH:mm:ss'))

     

    Thanks,

    Srini 

  • Rex2025 Profile Picture
    on at

    I put empty and I'm back to the original issue, every single value becomes null. 

     

    I know the values are there, if I remove any expressions and just put the value then it returns the date (in a bad format for me), it's just when I use the if(empty) I'm getting everything as null. 

  • Rex2025 Profile Picture
    on at

    I tried the trim formula, but that resulted in this: 

     

    Unable to process template language expressions in action 'Compose_-_Sharepoint_Data' inputs at line '0' and column '0': 'The provided parameters for template language function 'trim' are not valid.'.

  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

     Since empty(null) also returns true, I suspect that items('Apply_to_each_-_Sharepoint_Data')?['Closed Time']) does not exist. Try items('Apply_to_each_-_Sharepoint_Data')['Closed Time']) (without the question mark) and check if there is an error.

  • Rex2025 Profile Picture
    on at

    Thank you. I will try this tomorrow and report back. 

  • Rex2025 Profile Picture
    on at

    Question though - when I replace the expression with just the SharePoint value, it DOES return the date/time (just not in the format I need and I need to deal with null returns). So why would a field not exist? All of the other fields are returning fine. 

  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    Sorry, I'm just guessing 😉

    Without having seen more of you flow I cannot anwer this.

  • Rex2025 Profile Picture
    on at

    Here are some screenshots. 

    A137BDDB-0FD7-4A0C-94DF-30AB18BEC881.png

    8A0840D0-E765-46EC-B1C9-5CD32002D525.jpeg

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 468

#2
Haque Profile Picture

Haque 370

#3
Valantis Profile Picture

Valantis 354

Last 30 days Overall leaderboard