Forum Discussion
DLX_Ares_SP
2 years agoRegular Visitor
Loop in M query
Hi, I am trying to make a loop with an M query, but I can't find the solution. First, why I want to do it: I am getting information via API from one of the platforms we use in our company. I ...
AlienSx
2 years agoSuper User
Hi, DLX_Ares_SP make a custom function out of your "actual query without the loop" with dates as parameters, transform dates using Date.ToText like this:
my_little_query = (sd as date, ed as date) =>
let
StartDate = Date.ToText(sd),
EndDate = DateToText(ed),
<the rest of your original query>use optional parameters of Date.ToText to control it's text output. Then you may use Table.AddColumn in your Date_ranges query to feed this custom function with StartOfMonth and EndOfMonth to get a column with tables:
Table.AddColumn(
#"Duplicados quitados", "tables",
(x) => my_little_query(x[StartOfMonth], x[EndOfMonth])
)Then you may expand this new column with tables the way you want.