Forum Discussion

jdusek92's avatar
jdusek92
Advocate III
7 years ago
Solved

M formula explanation - Table.SelectRows

Hello,

I have successfully applied the solution from this post.

Now I would like to understand the logic.

 

scenario:

(simplified)

  1. data table with employees ID, Month and value for the respective month
  2. correction data table with ID, correct value, "valid from month" and "valid to month"

The task is to correct the data with the values from correction table, for given ID and months

 

 

I have this M formula, that WORKS:

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="kons"]}[Content],
    zmenyBuf = Table.Buffer(zmeny),
    #"Added Custom" = Table.AddColumn(Source, "NovySl", (tempNazev) => Table.SelectRows(zmenyBuf,each tempNazev [m]>= [od] and  tempNazev [m]<= [do] and tempNazev [ID]=[ID]), Value.Type(zmenyBuf)),
    #"Expanded zmeny" = Table.ExpandTableColumn(#"Added Custom", "NovySl", {"hod"}, {"NovySl.hod"})
in
    #"Expanded zmeny"

 

 

I would like to understand this part:

what is the purpose of tempNazev ? Is that just a placeholder?

 

(tempNazev) => Table.SelectRows(zmenyBuf,each tempNazev [m]>= [od] and  tempNazev [m]<= [do] and tempNazev [ID]=[ID]), Value.Type(zmenyBuf)

 

 

Warm regards,

Jakub

3 Replies