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

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
Community Support Team
Community Support Team

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.
3 REPLIES 3
Community Support Team
Community Support Team

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
mandy4514
Level: Powered On

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.

Community Support Team
Community Support Team

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.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 412 members 5,120 guests
Please welcome our newest community members: