Forum Discussion

Delryin's avatar
Delryin
Copper Contributor
Oct 25, 2021
Solved

PowerApps - If Statement, if value ctry is blank, shows everything.

Good afternoon,

 

I'm still leaning PowerApps so I apologise if this is so simple I could not see it.

I have 5 value that I use for filtering a recordset (just counting the number of rows that matches criteria):

obs_date

ctry

ste

prt

 

The record set is based on another value: Orgn (this one is hardcoded, I'am actually counting the rows that include that value).

 

The following is working nicely:

CountIf(

Filter(table;fld.Obs_Date = obs_date.SelectedDate && Ctry = ctry.SelectedText.Value && Ste = ste.SelectedText.Value && Prt = prt.Text);

Orgn = "Value I'm looking for")

 

However, it works only if all values are entered.... Let's imagine that I want all records associated with "ctry' regardless of the other data (leaving them blank)... then nothing shows.

 

I've been trying something along these lines:

CountIf(

Filter(table;fld.Obs_Date = obs_date.SelectedDate && If(Not(ctry.SelectedText.Value="--"); Ctry = ctry.SelectedText.Value)

But that gives me an error "receive only 1 statement when expecting 2 or more". Which also seems perfectly logical, the app sees the "&&" and expects something.

I'd be looking for a way to cancel the "&&" or give a value that does not filter any result if my ctry is equal to "--" or blank.

 

Any advice?

Regards

Delryin

Resources