Forum Discussion
mmiklauz1
1 year agoRegular Visitor
Extra rows vs second table
Hi everyone, I'm struggling a few days whit this problem so I would appreciate your help. I need create a dynamic measure to show only the "extra rows" i each table: so for example I have two source...
- 1 year ago
Hi mmiklauz1,
Thank you for reaching out to the Microsoft Fabric Forum Community. I’ve gone ahead and reproduced your scenario using Power Query.
Below is the M code I used in Power BI to reproduce your scenario:let Table1 = #table({"Value"}, {{5},{5},{5},{5},{4},{3},{2},{1}}), Table2 = #table({"Value"}, {{5},{3},{2},{1}}), Table1Grouped = Table.Group(Table1, {"Value"}, {{"Count1", each Table.RowCount(_), Int64.Type}}), Table2Grouped = Table.Group(Table2, {"Value"}, {{"Count2", each Table.RowCount(_), Int64.Type}}), Merged = Table.NestedJoin(Table1Grouped, {"Value"}, Table2Grouped, {"Value"}, "T2", JoinKind.LeftOuter), Expanded = Table.ExpandTableColumn(Merged, "T2", {"Count2"}), WithReplacedNulls = Table.ReplaceValue(Expanded, null, 0, Replacer.ReplaceValue, {"Count2"}), WithExtra = Table.AddColumn(WithReplacedNulls, "Extra", each List.Max({[Count1] - [Count2], 0}), Int64.Type), Filtered = Table.SelectRows(WithExtra, each [Extra] > 0), WithRepeated = Table.AddColumn(Filtered, "Repeated", each List.Repeat({[Value]}, [Extra])), ExpandedRows = Table.ExpandListColumn(WithRepeated, "Repeated"), FinalOutput = Table.SelectColumns(ExpandedRows, {"Repeated"}), Renamed = Table.RenameColumns(FinalOutput, {{"Repeated", "Value"}}) in RenamedI’m also attaching the output screenshot and .pbix file here for your reference so you can explore it end-to-end:
If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
v-ssriganesh
1 year agoCommunity Support
Hi mmiklauz1,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.