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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / IF NULL: This should b...
Power Automate
Answered

IF NULL: This should be easy!!

(0) ShareShare
ReportReport
Posted on by

Not sure why this doesn't work. Can you spot the issue?

I just want to check if the timestamp coming across ("Observation_Date_Time") is null or not. If its null, write "1970-1-1 00:00:00", otherwise convert the timestamp from unix to human readable.

Works fine without the IF statement. "Invalid Expression" error with the IF. 

if(
 items(
 'For_each_childRecord')?
 ['attributes']?
 ['Observation_Date_Time']
 = null, //also tried = 0 //same error "invalid expression"
 '1970-1-1 00:00:00',
 addseconds(
 '1970-1-1',
 Div(
 items(
 'For_each_childRecord')?
 ['attributes']?
 ['Observation_Date_Time'],
 1000
 ),
 'yyyy-MM-dd hh:mm:ss'
 )
)  

 

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,278 Most Valuable Professional on at
    @ericonline
    Have you tried checking for an empty string? Try two single quotes and it may work

  • Community Power Platform Member Profile Picture
    on at

    Hi @ScottShearer 

    Just pasted this in:

    if(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     = '',
     '1970-1-1 00:00:00',
     addseconds(
     '1970-1-1',
     Div(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time'],
     1000
     ),
     'yyyy-MM-dd hh:mm:ss'
     )
    )

    Results:

    image.png

  • RezaDorrani Profile Picture
    12,143 on at

    Hi @ericonline 

     

    write a compose action and check output for 

    items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']

     

    Regards,

    Reza Dorrani

     

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

  • RezaDorrani Profile Picture
    12,143 on at

    Hi @ericonline 

     

    you can also try

     

    empty(items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time'])

    which should return a true or a false 

  • Community Power Platform Member Profile Picture
    on at

    Hi @RezaDorrani ,

     

    The Compose action for the null record yeilds:

    Note: All non-null Observation_Date_Time records showed the Unix time value

    image.png

    Clicking the link opens a blank browser window. Right click/view source, no content on the page. 

  • RezaDorrani Profile Picture
    12,143 on at

    @ericonline 

     

    perfect now try

     

    equals(items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     ,null)

    empty(items( 'For_each_childRecord')? ['attributes']? ['Observation_Date_Time'])

     

    In compose actions to see the results

  • Community Power Platform Member Profile Picture
    on at

    @RezaDorrani 

     

    `empty()` failed all records in the Flow. 

     

    Tried:

    if(
     empty(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     ),
     '1970-1-1 00:00:00',
     addseconds(
     '1970-1-1',
     Div(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time'],
     1000
     ),
     'yyyy-MM-dd hh:mm:ss'
     )
    )

    Results:

    image.png

  • Verified answer
    RezaDorrani Profile Picture
    12,143 on at

    Hi @ericonline 

     

    and what about

     

    equals(items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     ,null)

    equals(items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     ,'')
  • Community Power Platform Member Profile Picture
    on at

    @RezaDorrani

    NICE!

    `equals(XYZ,null)` worked. 

    Solution:

    if(
     equals(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time'],
     null),
     '1970-1-1 00:00:00',
     addseconds(
     '1970-1-1',
     Div(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time'],
     1000
     ),
     'yyyy-MM-dd hh:mm:ss'
     )
    )

    Results for the null-value timestamp record:

    image.png

    Thank you both for the Flow expertise! 

    Take care!

  • Community Power Platform Member Profile Picture
    on at

    Esoteric syntax! Would have loved to use: 

    if(
     items(
     'For_each_childRecord')?
     ['attributes']?
     ['Observation_Date_Time']
     = null

    Ah well, these are the types of things that make us valuable I guess. 

    Thank you again Reza. I look forward to the TDGI event! 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 248 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 207 Super User 2026 Season 1

#3
Power Platform 1919 Profile Picture

Power Platform 1919 101 Super User 2026 Season 1

Last 30 days Overall leaderboard