I have a simple form and what to compare 2 values
If(TotalComp>TotalMonths,"Yes","No")
This is what I think the value should be but it does not work
When the user enters a DOB this calculates the age into months as a label This is TotalMonths
If (DateDiff (Today (), Date (Year (Now ()), Month (DataCardValue1.SelectedDate), Day (DataCardValue1.SelectedDate))) <= 0, DateDiff (DataCardValue1.SelectedDate, Today (),TimeUnit.Months),DateDiff (DataCardValue1.SelectedDate, Today (),TimeUnit.Months) - 1)
I then have a 2nd label which is the calculation of their comprehension age This is TotalComp
Sum(DataCardValue7*12 + DataCardValue8)
To auto-fill a choice column in a Form you will need to write the code in the DefaultSelectedItems property. In case the error occurs there as well, would it be possible to provide some additional info:
That works perfectly : )
How would I adapt it for a dropdown box? or as part of a form?
If( Value(TotalComp.Text) > Value(TotalMonths.Text), {Value: "Yes"}, {Value: "No"} )
@BCWdesign if you want to visualize it in a label or textinput, we will need to make a slight adjustment:
If(
Value(TotalComp.Text) > Value(TotalMonths.Text),
"Yes",
"No"
)
Could you give this a try? 😊
Thanks still having issues with the type here is what happens
Hi @BCWdesign,
If the combobox is a choice field please try (DefaultSelectedItems property):
If(
Value(TotalComp.Text) > Value(TotalMonths.Text),
{Value: "Yes"},
{Value: "No"}
)
When comparing control values, always extend the control name with the property you would like to reference (e.g. .Text). Additionally, when comparing numbers within a label or text input use the Value() function.
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!
WarrenBelz
223
Most Valuable Professional
MS.Ragavendar
110
Michael E. Gernaey
89
Super User 2025 Season 1