cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ruchiga
Level: Powered On

Repeat and Blank Value Collection

What's another way other than writing every line 25 times? Any ideas?

If the value of Hours is blank, this should not go to the BACollect or SPList. How?

 

ClearCollect(BACollect,
{BU: DDBU.Selected.Value,Country:ddCountry.Selected.Value,Hours: Value(txtHour.Text)},
{BU: DDBU_1.Selected.Value,Country:ddCountry_1.Selected.Value,Hours: Value(txtHour_1.Text)},
{BU: DDBU_2.Selected.Value,Country:ddCountry_2.Selected.Value,Hours: Value(txtHour_2.Text)},
...
...
...
...

);

ForAll(BACollect,Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft RusselThomas
Microsoft

Re: Repeat and Blank Value Collection

Hi @ruchiga ,

That looks like a lot of hard work Smiley Wink

I assume you want to add some logic to the collection to exclude Blank() hours - and want to avoid having to add that logic to each line.  If I'm correct, just wrap your collection in a filter as part of the ForAll Patch - something like this;

ForAll(
          Filter(BACollect, !IsBlank(Hours)),
Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

Hope this helps,

RT

View solution in original post

2 REPLIES 2
Highlighted
Microsoft RusselThomas
Microsoft

Re: Repeat and Blank Value Collection

Hi @ruchiga ,

That looks like a lot of hard work Smiley Wink

I assume you want to add some logic to the collection to exclude Blank() hours - and want to avoid having to add that logic to each line.  If I'm correct, just wrap your collection in a filter as part of the ForAll Patch - something like this;

ForAll(
          Filter(BACollect, !IsBlank(Hours)),
Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

Hope this helps,

RT

View solution in original post

ruchiga
Level: Powered On

Re: Repeat and Blank Value Collection

I will get back to you shortly about blank() today.

 

I have about 50 controls. I don't want to copy and paste and change the number like the below example. What's another way other than copying/pasting and changing 25 times? Is there any easy code for this like for loop? 

 

ClearCollect(BACollect,
{BU: DDBU.Selected.Value,Country:ddCountry.Selected.Value,Hours: Value(txtHour.Text)},
{BU: DDBU_1.Selected.Value,Country:ddCountry_1.Selected.Value,Hours: Value(txtHour_1.Text)},
{BU: DDBU_2.Selected.Value,Country:ddCountry_2.Selected.Value,Hours: Value(txtHour_2.Text)},
...
...
...
...

);

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,549)