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

RoundDown and Search in the Same Gallery.

Hi! I would like to separate the transections in a gallery and use the coding below

for go to the first-page button.

 

UpdateContext(
    {
        iter: RoundDown(
            Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
            0
        )
    }
);
FirstN(
    col_insuranceData,
    iter
)

 

for previous page button

 

If(
    iter < 2 * RoundDown(
        Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
        0
    ),
    UpdateContext(
        {
            iter: RoundDown(
                Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                0
            )
        }
    );
    FirstN(
        col_insuranceData,
        iter
    ),
    UpdateContext(
        {
            iter: iter - RoundDown(
                Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                0
            )
        }
    )
)

 

for next-page button

 

If(
    iter < CountRows(col_insuranceData),
    UpdateContext(
        {
            iter: If(
                iter < CountRows(col_insuranceData),
                iter + RoundDown(
                    Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                    0
                )
            )
        }
    )
)

 

for last-page button

 

UpdateContext({iter: CountRows(col_insuranceData)}); LastN(col_insuranceData, iter)

 

and in the Gallery Item

 

LastN(FirstN(col_insuranceData, iter), RoundDown(Gallery_LicenseSearch.Height/Gallery_LicenseSearch.TemplateHeight,0))

 

 

Everything can use but when I get the code for search in Gallery Item like the picture below it has an error.

 

infinitepp_0-1619694654194.png

 

Thank you so much for the help in advance! 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @infinitepp :

I have provided detailed steps and codes in the previous solution. If you need to combine these two functions, you need to combine these two formulas in a nested way instead of simply using || or, connect them.(In addition, the formulas in other buttons also need to be modified)

The Code should be:

 

LastN(FirstN(

If(
dd_licenceType_2.Selected.Result = "ทั้งหมด",
col_in,
Filter(
col_in,
Or(
txtSearchLicense_3.Text in SaleCode,
txtSearchLicense_3.Text in sale_FName,
txtSearchLicense_3.Text in sale_LName
) && license_name = dd_licenceType_2.Selected.Result
)
)

, iter)

 

Best Regards,

Bof

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @infinitepp :

Firstly,let me explain why you encountered this problem.

The point is syntax error.

The value of "LastN(……)" is a Table

The value of "If(xx,Table1,Filter(Table……))" is an other table

So your Gallery's items property looks like this:

Table1,Table2

It's wrong.The point is that one gallery cannot use two tables as its data source at the same time.

Secondly,If you need to combine the two functions,my suggestion is to replace all 

col_insuranceData

with

If(XX,col_insuranceData,Filter(col_insuranceData,XXX))

For example:

for go to the first-page button.

UpdateContext(
    {
        iter: RoundDown(
            Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
            0
        )
    }
);
FirstN(
    If(XX,col_insuranceData,Filter(col_insuranceData,XXX)),
    iter
)

for previous page button

If(
    iter < 2 * RoundDown(
        Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
        0
    ),
    UpdateContext(
        {
            iter: RoundDown(
                Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                0
            )
        }
    );
    FirstN(
        If(XX,col_insuranceData,Filter(col_insuranceData,XXX)),
        iter
    ),
    UpdateContext(
        {
            iter: iter - RoundDown(
                Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                0
            )
        }
    )
)

for next-page button

If(
    iter < CountRows(If(XX,col_insuranceData,Filter(col_insuranceData,XXX))),
    UpdateContext(
        {
            iter: If(
                iter < CountRows(If(XX,col_insuranceData,Filter(col_insuranceData,XXX))),
                iter + RoundDown(
                    Gallery_LicenseSearch.Height / Gallery_LicenseSearch.TemplateHeight,
                    0
                )
            )
        }
    )
)

for last-page button

UpdateContext({iter: CountRows(If(XX,col_insuranceData,Filter(col_insuranceData,XXX)))}); LastN(If(XX,col_insuranceData,Filter(col_insuranceData,XXX)), iter)

and in the Gallery Item

LastN(FirstN(If(XX,col_insuranceData,Filter(col_insuranceData,XXX)), iter), RoundDown(Gallery_LicenseSearch.Height/Gallery_LicenseSearch.TemplateHeight,0))

Best Regards,

Bof

 

Thank you for your explanation I have got the knowledge from that a lot. But I'm really sure the collection that col_insuranceData is just only one Collection table is connected with the Gallery. 

The problem is I have no idea how to get searching code after LastN(FirstN(col_insuranceData, iter), RoundDown(Gallery_LicenseSearch.Height/Gallery_LicenseSearch.TemplateHeight,0))

and this is the code for searching.

If(
    dd_licenceType_2.Selected.Result = "ทั้งหมด",
    col_in,
    Filter(
        col_in,
        Or(
            txtSearchLicense_3.Text in SaleCode,
            txtSearchLicense_3.Text in sale_FName,
            txtSearchLicense_3.Text in sale_LName
        ) && license_name = dd_licenceType_2.Selected.Result
    )
)

 

I tried to use || & && , but syntax error.😔

 

Thank you.

Hi @infinitepp :

I have provided detailed steps and codes in the previous solution. If you need to combine these two functions, you need to combine these two formulas in a nested way instead of simply using || or, connect them.(In addition, the formulas in other buttons also need to be modified)

The Code should be:

 

LastN(FirstN(

If(
dd_licenceType_2.Selected.Result = "ทั้งหมด",
col_in,
Filter(
col_in,
Or(
txtSearchLicense_3.Text in SaleCode,
txtSearchLicense_3.Text in sale_FName,
txtSearchLicense_3.Text in sale_LName
) && license_name = dd_licenceType_2.Selected.Result
)
)

, iter)

 

Best Regards,

Bof

View solution in original post

Thanks! Now It works for me.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,345)