SOLVED

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

Copper Contributor

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

2 Replies
best response confirmed by VI_Migration (Silver Contributor)
Solution
Basically you want to include or statements in your filter for other possible values like isblank(value) or value = "--". Check out this article fir an example of how to do this:
http://powerappsguide.com/blog/post/filter-or-to-return-all-records-when-no-search-term-entered

@BrendanE1535 

 

Thanks, I'll give this a try.

1 best response

Accepted Solutions
best response confirmed by VI_Migration (Silver Contributor)
Solution
Basically you want to include or statements in your filter for other possible values like isblank(value) or value = "--". Check out this article fir an example of how to do this:
http://powerappsguide.com/blog/post/filter-or-to-return-all-records-when-no-search-term-entered

View solution in original post