cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Add a column to a database then do a switch on how gallery is filtered

I have a gallery that is using a text box and a date picker to search the gallery below depending on which field is selected in the drop down.  The Gallery Items is set to: 

Switch(CBSearch.Selected.Value,"Store Name",Filter('[dbo].[D_LocProjTracking]',StartsWith(Name,SearchText1.Text)),"SiteID",Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteID,SearchText1.Text)),"Store Number",Filter('[dbo].[D_LocProjTracking]',StartsWith(Store,SearchText1.Text)),"Address",Filter('[dbo].[D_LocProjTracking]',StartsWith(Address,SearchText1.Text)),"Country",Filter('[dbo].[D_LocProjTracking]',StartsWith(Country,SearchText1.Text)),"City",Filter('[dbo].[D_LocProjTracking]',StartsWith(City,SearchText1.Text)),"State",Filter('[dbo].[D_LocProjTracking]',StartsWith(State,SearchText1.Text)),"Region",Filter('[dbo].[D_LocProjTracking]',StartsWith(Region,SearchText1.Text)),"DesignLead",Filter('[dbo].[D_LocProjTracking]',StartsWith(DesignLead,SearchText1.Text)),"SiteAdapt",Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteAdapt,SearchText1.Text)),"RDProgram",Filter('[dbo].[D_LocProjTracking]',StartsWith(RDProgram,SearchText1.Text)),"Phase",Filter('[dbo].[D_LocProjTracking]',StartsWith(Phase,SearchText1.Text)),"DDReceived",Filter('[dbo].[D_LocProjTracking]',StartsWith(DDReceived,SearchText1.Text)),"CUPStart",Filter('[dbo].[D_LocProjTracking]',CUPStart=SearchDatePicker1.SelectedDate),"CUPEnd",Filter('[dbo].[D_LocProjTracking]',CUPEnd=SearchDatePicker1.SelectedDate),"SUPStart",Filter('[dbo].[D_LocProjTracking]',SUPStart=SearchDatePicker1.SelectedDate),"SUPEnd",Filter('[dbo].[D_LocProjTracking]',SUPEnd=SearchDatePicker1.SelectedDate),"SDStart",Filter('[dbo].[D_LocProjTracking]',SDStart=SearchDatePicker1.SelectedDate),"SDEnd",Filter('[dbo].[D_LocProjTracking]',SDEnd=SearchDatePicker1.SelectedDate),"DIPStart",Filter('[dbo].[D_LocProjTracking]',DIPStart=SearchDatePicker1.SelectedDate),"DIPEnd",Filter('[dbo].[D_LocProjTracking]',DIPEnd=SearchDatePicker1.SelectedDate),"PermitSub",Filter('[dbo].[D_LocProjTracking]',PermitSub=SearchDatePicker1.SelectedDate),"BID",Filter('[dbo].[D_LocProjTracking]',BID=SearchDatePicker1.SelectedDate),"ConstStart",Filter('[dbo].[D_LocProjTracking]',ConstStart=SearchDatePicker1.SelectedDate),"ConstEnd",Filter('[dbo].[D_LocProjTracking]',ConstEnd=SearchDatePicker1.SelectedDate),"GO",Filter('[dbo].[D_LocProjTracking]',GO=SearchDatePicker1.SelectedDate),"ContractComm",Filter('[dbo].[D_LocProjTracking]',ContractComm=SearchDatePicker1.SelectedDate),"SAInfo",Filter('[dbo].[D_LocProjTracking]',StartsWith(SAInfo,SearchText1.Text)))

 

I need to AddColumn called "Selected" and set it to default unless the item is actually selected. 

AddColumns('[dbo].[D_LocProjTracking]',"CustomSelected",false)

 

this way nothing is selected by default.

 

How can I combine my switch and Addcolumns formulas?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Add a column to a database then do a switch on how gallery is filtered

Hi @mandy4514 ,

Do you mean that before the drop down is selected, you want the gallery display all items?

If so, I suggest you use a variable to justify whther the drop down is selected.

I'm made a similar test for your reference:

1)Set the screen's OnVisible: Set(var1,true)

2)Set the drop down's OnChange: Set(var1,false)

3)Set the gallery's Items:

If(var1,'[dbo].[D_LocProjTracking]',
Switch(CBSearch.Selected.Value,
"Store Name",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Name,SearchText1.Text)),
"SiteID",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteID,SearchText1.Text)),
"Store Number",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Store,SearchText1.Text)),
"Address",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Address,SearchText1.Text)),
"Country",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Country,SearchText1.Text)),
"City",
Filter('[dbo].[D_LocProjTracking]',StartsWith(City,SearchText1.Text)),
"State",
Filter('[dbo].[D_LocProjTracking]',StartsWith(State,SearchText1.Text)),
"Region",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Region,SearchText1.Text)),
"DesignLead",
Filter('[dbo].[D_LocProjTracking]',StartsWith(DesignLead,SearchText1.Text)),
"SiteAdapt",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteAdapt,SearchText1.Text)),
"RDProgram",
Filter('[dbo].[D_LocProjTracking]',StartsWith(RDProgram,SearchText1.Text)),
"Phase",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Phase,SearchText1.Text)),
"DDReceived",
Filter('[dbo].[D_LocProjTracking]',StartsWith(DDReceived,SearchText1.Text)),
"CUPStart",
Filter('[dbo].[D_LocProjTracking]',CUPStart=SearchDatePicker1.SelectedDate),
"CUPEnd",
Filter('[dbo].[D_LocProjTracking]',CUPEnd=SearchDatePicker1.SelectedDate),
"SUPStart",
Filter('[dbo].[D_LocProjTracking]',SUPStart=SearchDatePicker1.SelectedDate),
"SUPEnd",
Filter('[dbo].[D_LocProjTracking]',SUPEnd=SearchDatePicker1.SelectedDate),
"SDStart",
Filter('[dbo].[D_LocProjTracking]',SDStart=SearchDatePicker1.SelectedDate),
"SDEnd",
Filter('[dbo].[D_LocProjTracking]',SDEnd=SearchDatePicker1.SelectedDate),
"DIPStart",
Filter('[dbo].[D_LocProjTracking]',DIPStart=SearchDatePicker1.SelectedDate),
"DIPEnd",
Filter('[dbo].[D_LocProjTracking]',DIPEnd=SearchDatePicker1.SelectedDate),
"PermitSub",
Filter('[dbo].[D_LocProjTracking]',PermitSub=SearchDatePicker1.SelectedDate),
"BID",
Filter('[dbo].[D_LocProjTracking]',BID=SearchDatePicker1.SelectedDate),
"ConstStart",
Filter('[dbo].[D_LocProjTracking]',ConstStart=SearchDatePicker1.SelectedDate),
"ConstEnd",
Filter('[dbo].[D_LocProjTracking]',ConstEnd=SearchDatePicker1.SelectedDate),
"GO",
Filter('[dbo].[D_LocProjTracking]',GO=SearchDatePicker1.SelectedDate),
"ContractComm",
Filter('[dbo].[D_LocProjTracking]',ContractComm=SearchDatePicker1.SelectedDate),
"SAInfo",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SAInfo,SearchText1.Text))
)
)

At the beginning var1 is true by default, so the gallery display all items.

If you select value in the drop down, var1 will become false, then gallery's Items filter based on the formula that you provided.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Add a column to a database then do a switch on how gallery is filtered

Hi @mandy4514 ,

Could you describe more clearly about "set it to default unless the item is actually selected"?

What do you want to use this AddColumns function to do ?

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper I
Helper I

Re: Add a column to a database then do a switch on how gallery is filtered

@v-yutliu-msft 

 

I am trying to create my own select. I want the gallery by default to have nothing selected. But when I click on a gallery item I want that item to be selected. So I am trying to create a new CustomSelected column that by default is set to false then when clicked set to true.  See: https://powerusers.microsoft.com/t5/Video-Gallery/Galleries-No-Default-Selected-Item-Multiple-Select.... But the gallery is set to the switch fucntion to allow a drop down to select which column to search then use a text box or date picker to input what to search in that column.

 

Hope this helps to explain the need.

Highlighted
Community Support
Community Support

Re: Add a column to a database then do a switch on how gallery is filtered

Hi @mandy4514 ,

Do you mean that before the drop down is selected, you want the gallery display all items?

If so, I suggest you use a variable to justify whther the drop down is selected.

I'm made a similar test for your reference:

1)Set the screen's OnVisible: Set(var1,true)

2)Set the drop down's OnChange: Set(var1,false)

3)Set the gallery's Items:

If(var1,'[dbo].[D_LocProjTracking]',
Switch(CBSearch.Selected.Value,
"Store Name",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Name,SearchText1.Text)),
"SiteID",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteID,SearchText1.Text)),
"Store Number",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Store,SearchText1.Text)),
"Address",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Address,SearchText1.Text)),
"Country",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Country,SearchText1.Text)),
"City",
Filter('[dbo].[D_LocProjTracking]',StartsWith(City,SearchText1.Text)),
"State",
Filter('[dbo].[D_LocProjTracking]',StartsWith(State,SearchText1.Text)),
"Region",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Region,SearchText1.Text)),
"DesignLead",
Filter('[dbo].[D_LocProjTracking]',StartsWith(DesignLead,SearchText1.Text)),
"SiteAdapt",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SiteAdapt,SearchText1.Text)),
"RDProgram",
Filter('[dbo].[D_LocProjTracking]',StartsWith(RDProgram,SearchText1.Text)),
"Phase",
Filter('[dbo].[D_LocProjTracking]',StartsWith(Phase,SearchText1.Text)),
"DDReceived",
Filter('[dbo].[D_LocProjTracking]',StartsWith(DDReceived,SearchText1.Text)),
"CUPStart",
Filter('[dbo].[D_LocProjTracking]',CUPStart=SearchDatePicker1.SelectedDate),
"CUPEnd",
Filter('[dbo].[D_LocProjTracking]',CUPEnd=SearchDatePicker1.SelectedDate),
"SUPStart",
Filter('[dbo].[D_LocProjTracking]',SUPStart=SearchDatePicker1.SelectedDate),
"SUPEnd",
Filter('[dbo].[D_LocProjTracking]',SUPEnd=SearchDatePicker1.SelectedDate),
"SDStart",
Filter('[dbo].[D_LocProjTracking]',SDStart=SearchDatePicker1.SelectedDate),
"SDEnd",
Filter('[dbo].[D_LocProjTracking]',SDEnd=SearchDatePicker1.SelectedDate),
"DIPStart",
Filter('[dbo].[D_LocProjTracking]',DIPStart=SearchDatePicker1.SelectedDate),
"DIPEnd",
Filter('[dbo].[D_LocProjTracking]',DIPEnd=SearchDatePicker1.SelectedDate),
"PermitSub",
Filter('[dbo].[D_LocProjTracking]',PermitSub=SearchDatePicker1.SelectedDate),
"BID",
Filter('[dbo].[D_LocProjTracking]',BID=SearchDatePicker1.SelectedDate),
"ConstStart",
Filter('[dbo].[D_LocProjTracking]',ConstStart=SearchDatePicker1.SelectedDate),
"ConstEnd",
Filter('[dbo].[D_LocProjTracking]',ConstEnd=SearchDatePicker1.SelectedDate),
"GO",
Filter('[dbo].[D_LocProjTracking]',GO=SearchDatePicker1.SelectedDate),
"ContractComm",
Filter('[dbo].[D_LocProjTracking]',ContractComm=SearchDatePicker1.SelectedDate),
"SAInfo",
Filter('[dbo].[D_LocProjTracking]',StartsWith(SAInfo,SearchText1.Text))
)
)

At the beginning var1 is true by default, so the gallery display all items.

If you select value in the drop down, var1 will become false, then gallery's Items filter based on the formula that you provided.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,955)