Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 has too many rows and the data cannot be loaded within the 5hours limit of Service, but this is not the question. So we decideded, that the query will be loaded by years).
The question is, if in power query it is posible to excecute conditionaly some statements or invoke some function. somthing like in C++ (not define a conditional calculation of some column).
Some example:
- have a query A, which contain several columns to load,...
- than I need to invoke this query A and add some filter FA, and second invocation would need to have some filter FB.
- is it posible to define within the query A and condtion, base on some parameter like
if Parm1=1 then do filter FA
else do filter FB
(FA, FB are some fitering statements written in Power query)
I found out, that I can store the query A as function, then invoke it and just add the filter FA or FB. But this would create lot of aditional queries/function, whic is not so optimal for maintanance, as this would need to have defined query A_FA and A_FB,... and call them as separete invocation.
Solved! Go to Solution.
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
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 17 | |
| 9 | |
| 9 | |
| 7 | |
| 7 |