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 / Error The field has an...
Power Apps
Answered

Error The field has an invalid XAML formula definition - Calculated column with nested IF conditions

(0) ShareShare
ReportReport
Posted on by 120

I am trying to create a calculated column the sets the status of a contract depending on the Contract End Date field.

It is a single line text field

 

I can enter one condition:  If Contract End Date does not contain data then Set Contract Status to "no contract end date set"

But when I add an Else If condition I get the ContractStatus field has an invalid XAML formula definition.

What am I doing wrong?

ApppsApp_XAML error.png

 

 

 

 

 

 

 

 

 

 

I want to get to the following condition:

If Contract End Date does not contain data then Set Contract Status to "no contract end date set"

Else If Contract End Date <= Today then "Contract expired"

Else If Contract End Date > Today && <= Today + 9 months then "Contract expires within 9 next months"

Else "Contract Active"

 

I have created calculated columns in the same contracts table for the value of Today, Today() and Today + 9 months, DateAdd(Today(),9, TimeUnit.Months)

I have the same question (0)
  • Verified answer
    MarioRing Profile Picture
    541 Super User 2024 Season 1 on at

    There are two different features of the Dataverse:

    The second option is currently in the preview stage, which means it is not recommended to use it for production environments, and may not work properly in some cases. It looks like you can't combine both types of fields (I've checked a similar scenario on my environment and got the same error).

    What you can do:

    • Create one complex formula field using several nested PowerFx formulas to generate the desired output
      OR
    • Create scheduled power automate flow, which queries every day for Contracts, where "End date" == now(), and changes their statuses.
  • HMJ_Somerset Profile Picture
    120 on at

    Thanks for the advice.

    I have created a new column and used a Power fx formula to set the status:

    If(IsBlank('Contract End Date'), "No end date set",

        If('Contract End Date' <= UTCToday(), "Contract Expired",      

            If(And('Contract End Date'>= UTCToday(),

            'Contract End Date' <= DateAdd( UTCToday(),9,TimeUnit.Months)

    ),

            "Contract ends in 9 months",

        "Contract Active")))

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 525 Most Valuable Professional

#2
Haque Profile Picture

Haque 273

#3
Kalathiya Profile Picture

Kalathiya 232 Super User 2026 Season 1

Last 30 days Overall leaderboard