Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
This is my data:
I want to create the green column - a calculated column. It represents the name from max value of IDs AA and BB which both belong to the parent X. The relation is created between tables on the columns "ID". I tried this, but it failed:
Hi,
This M code works
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Parent", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, Table1, {"ID"}, "Table1", JoinKind.LeftOuter),
#"Expanded Table1" = Table.ExpandTableColumn(#"Merged Queries", "Table1", {"Value"}, {"Value"}),
#"Grouped Rows" = Table.Group(#"Expanded Table1", {"Parent"}, {{"Max", each List.Max([Value]), type number}}),
Joined = Table.Join(#"Expanded Table1", "Parent", #"Grouped Rows", "Parent"),
#"Removed Columns" = Table.RemoveColumns(Joined,{"Value"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
#"Merged Queries1" = Table.NestedJoin(#"Removed Duplicates", {"Max"}, Table1, {"Value"}, "Table1", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries1", "Table1", {"Name"}, {"Name"}),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Table2",{"Max"})
in
#"Removed Columns1"
Hope this helps.
Hi, @Zyg_D
You may create a calculated column as below.
Result =
var _parent = [Parent]
var _maxvalue =
CALCULATE(
MAX(Table1[Value]),
ALLEXCEPT(Table2,Table2[Parent])
)
return
CONCATENATEX(
CALCULATETABLE(
FILTER(
ALL(Table1),
Table1[Value] = _maxvalue&&
RELATED(Table2[Parent]) = _parent
)
),
[Name],","
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Zyg_D try this DAX expression by adding a column
Column =
VAR __ids = CALCULATETABLE ( VALUES ( Table2[id] ), ALLEXCEPT ( Table2, Table2[Parent] ) )
RETURN
CALCULATE ( MAX ( Table1[Name] ), ALL ( Table1 ), TREATAS( __ids, Table1[Id] ) )
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k wrote:@Zyg_D try this DAX expression by adding a column
Column =
VAR __ids = CALCULATETABLE ( VALUES ( Table2[id] ), ALLEXCEPT ( Table2, Table2[Parent] ) )
RETURN
CALCULATE ( MAX ( Table1[Name] ), ALL ( Table1 ), TREATAS( __ids, Table1[Id] ) )
I was too quick to accept this as solution. In your fomula MAX looks at [Name] and returns it. But I want it to look at [Value] while returning [Name].
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
104 | |
69 | |
48 | |
41 | |
34 |
User | Count |
---|---|
164 | |
111 | |
62 | |
53 | |
38 |