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!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hey guys!
I want the column of a "subquery" to be equal to the column of the current table.
Sample:
= Table.AddColumn(
NbrMonth,
"NmbCustomer",
each
Table.RowCount(
Table.SelectRows(
Table.Distinct(
Table.SelectColumns(
NbrMonth,{"Store","Op", "NF"}
)
),
each ([NF] = [NF]) //I want the [NF] column of this "subquery" to be equal to [NF] of the NbrMonth table.
)
)
Solved! Go to Solution.
This should do the trick:
= Table.AddColumn(
NbrMonth,
"NmbCustomer",
each
let OuterNF = [NF]
in
Table.RowCount(
Table.SelectRows(
Table.Distinct(
Table.SelectColumns(
NbrMonth,{"Store","Op", "NF"}
)
),
each ([NF] = OuterNF)
)
)
)
Regards,
Owen
Glad it worked 🙂
Sure - a "let expression" is used to capture values from intermediate calculations before returning a result.
It takes the form
let variable1 = expression1, variable2 = expression2, ... in result_expression
In your example, I used let OuterNF = [NF] to store the value of [NF] from the current row so that I could refer to it in the result expression. The resulting "let expression" formatted a little differently was:
let
OuterNF = [NF]
in
Table.RowCount(
Table.SelectRows(
Table.Distinct(
Table.SelectColumns(
NbrMonth,{"Store","Op", "NF"}
)
),
each ([NF] = OuterNF)
)
)Here is a link to the Power Query M language specification which might be useful for reference - see page 85 for let expressions:
https://msdn.microsoft.com/en-us/query-bi/m/power-query-m-language-specification
Best regards,
Owen
This should do the trick:
= Table.AddColumn(
NbrMonth,
"NmbCustomer",
each
let OuterNF = [NF]
in
Table.RowCount(
Table.SelectRows(
Table.Distinct(
Table.SelectColumns(
NbrMonth,{"Store","Op", "NF"}
)
),
each ([NF] = OuterNF)
)
)
)
Regards,
Owen
Glad it worked 🙂
Sure - a "let expression" is used to capture values from intermediate calculations before returning a result.
It takes the form
let variable1 = expression1, variable2 = expression2, ... in result_expression
In your example, I used let OuterNF = [NF] to store the value of [NF] from the current row so that I could refer to it in the result expression. The resulting "let expression" formatted a little differently was:
let
OuterNF = [NF]
in
Table.RowCount(
Table.SelectRows(
Table.Distinct(
Table.SelectColumns(
NbrMonth,{"Store","Op", "NF"}
)
),
each ([NF] = OuterNF)
)
)Here is a link to the Power Query M language specification which might be useful for reference - see page 85 for let expressions:
https://msdn.microsoft.com/en-us/query-bi/m/power-query-m-language-specification
Best regards,
Owen
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 61 | |
| 58 | |
| 42 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 105 | |
| 99 | |
| 38 | |
| 29 | |
| 29 |