I have this code that I'm getting an error on but I'm not sure what the issue is? I'm in europe so we use semicolon:
If(
!IsBlank(DataCardValue11_1.SelectedDate) && !IsBlank(DataCardValue13_1.SelectedDate);
DateAdd(
DataCardValue13_1.SelectedDate;
Switch(
RoundDown((Today() - DataCardValue11_1.SelectedDate) / 365; 0);
0; 5;
1 to 21 step 5; 5;
22 to 40 step 3; 3;
41 to 62 step 1; 1;
63 to 150 step 0; 1
);
TimeUnit.Years
);
Blank()
)
The formula uses the If function to check if both DataCardValue11_1.SelectedDate and DataCardValue13_1.SelectedDate are not blank. If both dates have been selected, the formula uses the DateAdd function to calculate a new date based on the second selected date (DataCardValue13_1.SelectedDate) and the number of years to add.
The number of years to add is determined by the Switch function, which takes the result of the RoundDown function as its first argument. The RoundDown function calculates the number of years between the first selected date (DataCardValue11_1.SelectedDate) and the current date (Today), and rounds down to the nearest whole number. This rounded down number of years is then used as an index for the Switch function.
The Switch function returns a different number of days to add depending on the rounded down number of years. For example, if the rounded down number of years is between 1 and 21 (inclusive), the formula adds 5 days to the second selected date. If the rounded down number of years is between 22 and 40 (inclusive), the formula adds 3 days. If the rounded down number of years is between 41 and 62 (inclusive), the formula adds 1 day. If the rounded down number of years is greater than 62, the formula also adds 1 day.
If either of the two selected dates is blank, the formula returns a blank value.