Forum Discussion
kmj97024
4 years agoNew Member
DAX with For/While Loop
Hi All, I created some DAX code which I want it to work as a For/While loop. I used this page as a reference. (https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/ba-p/6363...
- Anonymous4 years ago
Hi kmj97024 ,
You can try to use the following function:
LOOP - HR Analysis = VAR IndexNum = 1 VAR TotalValue = 0 VAR LoopTable = GENERATESERIES(1, 1) VAR LoopTable1 = ADDCOLUMNS(LoopTable, "SUM", TotalValue + SUMX(FILTER(LoopTable, [Value]<=EARLIER([Value])), SUMX(FILTER(ALL('HR Analysis'), 'HR Analysis'[Index]=[Value]), [LOOP - HR Analysis Value]))) VAR MaxInteraction = MAXX(LoopTable1, [Value]) RETURN MAXX(FILTER(LoopTable1, [Value]=MaxInteraction), [SUM])Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Anonymous
4 years agoNot applicable
Hi kmj97024 ,
You can try to use the following function:
LOOP - HR Analysis =
VAR IndexNum = 1
VAR TotalValue = 0
VAR LoopTable = GENERATESERIES(1, 1)
VAR LoopTable1 = ADDCOLUMNS(LoopTable, "SUM", TotalValue + SUMX(FILTER(LoopTable, [Value]<=EARLIER([Value])),
SUMX(FILTER(ALL('HR Analysis'),
'HR Analysis'[Index]=[Value]), [LOOP - HR Analysis Value])))
VAR MaxInteraction = MAXX(LoopTable1, [Value])
RETURN MAXX(FILTER(LoopTable1, [Value]=MaxInteraction), [SUM])
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly