cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mandy4514
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

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
v-yutliu-msft
Community Support
Community Support

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.

@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.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,267)