cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kcg633755
Level: Powered On

If null return value, If not null return formatdatetime

Hello,

 

I am scratching my head trying to find an expression to return a null value as TBC but if the value is not null return a date with date formatting.

 

Any suggestions?

 

I want to avoid using a condition if possible.

 

Many thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: If null return value, If not null return formatdatetime

Hi @kcg633755 ,

 

I have made a test on my side to create a "DueDateW" column, you could refer to my flow with expression as below:

1.png

The expression in the Compose as below:

if(empty(triggerBody()?['DueDateW']),'TBC',formatdatetime(triggerBody()?['DueDateW'],'dd/MM/yyyy'))

When I create a item in the list and the "DueDateW" column's value is null, the flow would run successfully as below:

2.png

When I create a item in the list and have value in the "DueDateW" column, the flow would run successfully as below:

3.png

 

 

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
kcg633755
Level: Powered On

Re: If null return value, If not null return formatdatetime

This is the expression I am using at the moment, it is causing the flow to crash...

 

if(equals(coalesce(triggerOutputs()?['body/12 - Date of Event:'],null),null),'00/00/0000',formatdatetime(triggerOutputs()?['body/12 - Date of Event:'],'dd/MM/yyyy'))
 
Any ideas?

@kcg633755 wrote:

Hello,

 

I am scratching my head trying to find an expression to return a null value as TBC but if the value is not null return a date with date formatting.

 

Any suggestions?

 

I want to avoid using a condition if possible.

 

Many thanks in advance.



kcg633755
Level: Powered On

Re: If null return value, If not null return formatdatetime

Screen Shot 2019-08-29 at 17.45.31.png

This is the message I get Smiley Mad

Community Support Team
Community Support Team

Re: If null return value, If not null return formatdatetime

Hi @kcg633755 ,

 

I have made a test on my side to create a "DueDateW" column, you could refer to my flow with expression as below:

1.png

The expression in the Compose as below:

if(empty(triggerBody()?['DueDateW']),'TBC',formatdatetime(triggerBody()?['DueDateW'],'dd/MM/yyyy'))

When I create a item in the list and the "DueDateW" column's value is null, the flow would run successfully as below:

2.png

When I create a item in the list and have value in the "DueDateW" column, the flow would run successfully as below:

3.png

 

 

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,436)