cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Usr21
Frequent Visitor

IF-Conditions with multiple statements

Hello everyone,

I set multiple variables for the IF-Conditions but it doesn't work.

 

# ###  VAR
SET TageZweiAcht TO FormattedDateMonth = 'Februar'
SET TageDreiNull TO FormattedDateMonth = 'April' OR FormattedDateMonth = 'Juni' OR FormattedDateMonth = 'September' OR FormattedDateMonth = 'Oktober'
SET TageDreiEins TO FormattedDateMonth = 'Januar' OR FormattedDateMonth = 'März' OR FormattedDateMonth = 'Mai' OR FormattedDateMonth = 'Juli' OR FormattedDateMonth = 'August' OR FormattedDateMonth = 'Oktober' OR FormattedDateMonth = 'Dezember'


# ###  DATE
DateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDateTime
Text.FromCustomDateTime DateTime: ResultedDate CustomFormat: $'''MMMM''' Result=> FormattedDateMonth

# ###  IF-COONDITIONS
IF FormattedDateMonth = TageZweiAcht THEN
    Display.ShowMessage Message: FormattedDateMonth Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

IF FormattedDateMonth = TageDreiNull THEN
    Display.ShowMessage Message: FormattedDateMonth Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

IF FormattedDateMonth = TageDreiEins THEN
    Display.ShowMessage Message: FormattedDateMonth Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

 

Do I make a mistake at the variables?

How can I set multiple variables for IF 🤔

1 ACCEPTED SOLUTION

Accepted Solutions
fraenK
Memorable Member
Memorable Member

The correct syntax is

IF (FormattedDateMonth = 'Januar' OR FormattedDateMonth = 'März') = True THEN

But it would be easier to create a list with all the months and then use "contains" like

IF %ListVariable% contains %FormattedDateMonth%

View solution in original post

4 REPLIES 4
fraenK
Memorable Member
Memorable Member
Usr21
Frequent Visitor

@fraenKthank you for your support! 👍

 

It doesn't also work

 

IF FormattedDateMonth = (TageDreiEins = 'Januar' OR TageDreiEins = 'März' OR TageDreiEins = 'Mai' OR TageDreiEins = 'Juli' OR TageDreiEins = 'August' OR TageDreiEins = 'Oktober' OR TageDreiEins = 'Dezember') THEN
    Display.ShowMessage Message: $'''%FormattedDateMonth%

%TageDreiEins%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

 

 

The variable "TageDreiEins" is false 🤔  

 

Flow.png

fraenK
Memorable Member
Memorable Member

The correct syntax is

IF (FormattedDateMonth = 'Januar' OR FormattedDateMonth = 'März') = True THEN

But it would be easier to create a list with all the months and then use "contains" like

IF %ListVariable% contains %FormattedDateMonth%

View solution in original post

Usr21
Frequent Visitor

@fraenK  best man! 😃

 

Here's my solution with a list contained all the month.

Maybe helps someone else

 

SET MonatDreiEins TO $'''Januar,  März, Mai, Juli, August, Oktober, Dezember'''
SET MonatDreiNull TO $'''April, Juni, September, November'''
SET MonatZweiAcht TO $'''Februar'''

DateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDateTime
DateTime.Add DateTime: CurrentDateTime TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> ResultedDate

Text.FromCustomDateTime DateTime: ResultedDate CustomFormat: $'''yyyy.MM''' Result=> FormattedDateTime
Text.FromCustomDateTime DateTime: ResultedDate CustomFormat: $'''MMMM''' Result=> FormattedDateMonth

IF Contains(MonatDreiEins, FormattedDateMonth, False) THEN
    Display.ShowMessage Title: $'''!!!''' Message: 31 Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
ELSE IF MonatDreiNull = FormattedDateMonth THEN
    Display.ShowMessage Title: $'''!!!''' Message: 30 Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
ELSE
    Display.ShowMessage Title: $'''!!!''' Message: 28 Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

 

 

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,505)