Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello.
I am wondering how the M code works. The code is as follows.
1. Each Table.RowCount (Table.SelectRows (# "Grouped Rows", (s) => s [TotalSales]> [TotalSales])) + 1, Int64.Type)
(s) => s [TotalSales]> [TotalSales])) + 1
I'm not sure, but in this formula, s [TotalSales] seems to work for multiple lines. [TotalSales] seems to work on a single row.
2. (s) => Table.RowCount (Table.SelectRows (# "Grouped Rows", each s [TotalSales] <[TotalSales])) + 1, Int64.Type)
Unlike number 1, in this formula, s [TotalSales] seems to act as a single row and [TotalSales] acts as multiple rows.
I'm curious about the difference between the two functions and how they work internally.
Solved! Go to Solution.
...
each Table.RowCount (Table.SelectRows (# "Grouped Rows", (s) => s [TotalSales]> [TotalSales])) + 1, Int64.Type)
...
this piece of code appears to be part (argument) of a function such as Table.AddColumn or similar.
the inner part of this piece: Table.SelectRows (# "Grouped Rows", (s) => s [TotalSales]> [TotalSales])
selects all rows of the # "Grouped Rows" table (which was probably created in the previous step) that satisfy the condition that the value of column s[TotalSales] is greater than the value _ [TotalSales] of the current row to which the anonymous function each (these selected lines are then counted +1)
the following is an equivalente form of the same expression:
...
(outer) => Table.RowCount (Table.SelectRows (# "Grouped Rows", (inner) => inner[TotalSales]> outer[TotalSales])) + 1, Int64.Type)
...
...
each Table.RowCount (Table.SelectRows (# "Grouped Rows", (s) => s [TotalSales]> [TotalSales])) + 1, Int64.Type)
...
this piece of code appears to be part (argument) of a function such as Table.AddColumn or similar.
the inner part of this piece: Table.SelectRows (# "Grouped Rows", (s) => s [TotalSales]> [TotalSales])
selects all rows of the # "Grouped Rows" table (which was probably created in the previous step) that satisfy the condition that the value of column s[TotalSales] is greater than the value _ [TotalSales] of the current row to which the anonymous function each (these selected lines are then counted +1)
the following is an equivalente form of the same expression:
...
(outer) => Table.RowCount (Table.SelectRows (# "Grouped Rows", (inner) => inner[TotalSales]> outer[TotalSales])) + 1, Int64.Type)
...
Thank you very much.
Thanks to that, it was well understood.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 5 | |
| 4 |