Forum Discussion
Yaroslav__D
1 year agoNew Member
Calculate Iterate Levels in M
Hi ALL! I tried to calculate in power query levels for my accounts to calculate all of them later . I used this code to do it , but is`s don`t work , maybe someone know what could be wrong? let...
v-priyankata
1 year agoCommunity Support
Hi Yaroslav__D
May I ask if you have resolved this issue? if not Please provide sample data so we can suggest a solution.
Thank you.
- Yaroslav__D1 year agoNew Member
Hi , no, this issue not resolved .
yes , sure , mappingrules looks literally like thisTargetAccount SourceAccount Operator P003099 P001010 + P003099 P002010 + P003099 P002030 + P008999 P003099 + P008999 P004050 + P013099 P013010 + P013099 P013020 + P013099 P013025 + P013099 P013030 + P013099 P013035 + P013099 P013040 + P013099 P013050 + P013099 P013062 + P013099 P013064 + P013099 P013070 + P013099 P013080 + P013099 P013095 + P014099 P014010 +
in Balance we have similar list where we find our Source Account , to give level 1 or null
Thanks- lbendlin1 year agoSuper User
consider using Expression.Evaluate
- v-priyankata1 year agoCommunity Support
Hi Yaroslav__D
Thank you for reaching out to the Microsoft Fabric Forum Community. sorry for delay.
Idea to use Expression.Evaluate is a really good one or Please try the code below. it may helps you. lbendlin Thanks for your inputs.
If the issue persists, feel free to reach out to us. We are happy to assist you.Table.TransformRows(
currentTable,
(row) =>
if row[Level] <> null then row
else
let
match = Table.SelectRows(DependencyMap, each [TargetAccount] = row[Account]),
sources = if Table.IsEmpty(match) then {} else match{0}[Sources],
allResolved = List.IsEmpty(List.Difference(sources, assignedAccounts))
in
if allResolved then Record.TransformFields(row, {{"Level", each currentLevel + 1}})
else row
)