Forum Discussion

tomas12344's avatar
tomas12344
Icon for Helper III rankHelper III
2 years ago
Solved

Conditionally invoke function or run statement

Hi All Customer want to load some data from SAP query, but the problem is, that in this case I have to call several times this query with different filters (basic probelm is that the query in SAP ha...
  • ManuelBolz's avatar
    2 years ago

    Hello tomas12344,

    I'm not sure if I understood you correctly. But maybe the following code will help you.

    let
        LoadSAPData = (FilterParameter as text) as table =>
        let
            Source = ... , // YOUR SAP QUERY
            FilteredData = if FilterParameter = "FA" then
                              Table.SelectRows(Source, each [YearColumn] = 2020)
                           else if FilterParameter = "FB" then
                              Table.SelectRows(Source, each [YearColumn] = 2021)
                           else
                              Source
        in
            FilteredData
    in
        LoadSAPData


    Best regards from Germany
    Manuel Bolz


    If this post helped you, please consider Accept as Solution so other members can find it faster.

    🤝Follow me on LinkedIn