cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dbatllevz
Frequent Visitor

Combine two formulas in a gallery

Hi all,

 

I have been developing some apps but now I having an issue in a gallery that I cannot solve

 

First I filtered a gallery related to table 1 by using a Dropdown, the formula works

 

If(Dropdown1.Selected.Result = "All";Table1;Filter(Table1;Column1= Dropdown1.Selected.Result))

 

Then I was asked to add a column from table 2 to the gallery, this formula also works

 

AddColumns(Table1;"ColumnXY";LookUp(Table2;ColumnX =Table1[@ColumnX];ColumnY))

 

Both formulas work perfectly separately however, now I want to put it together that I have the added column in the gallery but also I can filter it by using the dropdown

 

Does someone know how to combine both formulas?

 

Many thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Your If() statement is not the same as the one I posted above.  
If(Dropdown1.Selected.Result = "All";tbl;Table1;Filter(tbl;Table1;Column1= Dropdown1.Selected.Result))

View solution in original post

4 REPLIES 4
Drrickryp
Super User II
Super User II

Hi @dbatllevz  

 

 

With({tbl: AddColumns(
                      Table1;"ColumnXY";LookUp(
                                                Table2;ColumnX =Table1[@ColumnX];ColumnY
                                         )
            )}
 );
If(
    Dropdown1.Selected.Result = "All" ; tbl ; 
                                            Filter(
                                                    tbl;Column1= Dropdown1.Selected.Result
                                             )
)

 

 

 

 

Hi @Drrickryp , many thanks for your fast answer!

 

I tried as you mentioned:

With({tbl:AddColumns(Table1;"ColumnXY";LookUp(Table2;ColumnX=Table1[@ColumnX];ColumnY))});;If(Dropdown1.Selected.Result = "All";tbl;Table1;Filter(tbl;Table1;Column1= Dropdown1.Selected.Result))

 

Unfortunately is giving me "Invalid argument type" error

 

No clue what is wrong here, could you please help?

Your If() statement is not the same as the one I posted above.  
If(Dropdown1.Selected.Result = "All";tbl;Table1;Filter(tbl;Table1;Column1= Dropdown1.Selected.Result))

View solution in original post

Hi @Drrickryp  many thanks for the remark, it works now!

 

I had to delete the ) after } and put it in the end:

 

With({tbl:AddColumns(Table1;"ColumnXY";LookUp(Table2;ColumnX=Table1[@ColumnX];ColumnY))});;If(Dropdown1.Selected.Result = "All";tbl;Filter(tbl;Column1= Dropdown1.Selected.Result)))

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,404)