Forum Discussion
FOR loop equivalent in DAX?
Refer to https://gregdeckler.com
Greg_Deckler I'll take a look.
Does this mean you don't think I'm crazy, and there is a ray of hope?
Thanks,
-R
- Greg_Deckler6 years agoCommunity ChampionWell, I wrote a blog article on how to emulate a FOR loop and a WHILE loop in DAX. Also an article on emulating recursion. You're not crazy.
- Anonymous6 years agoNot applicable
Hi Greg_Deckler ,
Read through the blog post, generally makes sense without going and writing my own.
In thinking my situtation through though, I think I'm still stuck...
Using your approach here is how I think it would play out for me.
I have a table with an index that by virtue of its columns defines all the various combinations (rows). Using your approach we would iterate through each row, and for each row I could use the MAXX formulas to find the values for those rows (my conditions). Great, now I could say "do X" for this particular condition, and I didn't have to spell out each condition. Where I think I'm going to get stuck though is the "do X" I want is to assign a specific measure to that condition and I don't see a way to (through logic) specifiy use this Measure for this condition unlees there is a clever way to just add a bunch of measures to a single column in table and index it, then I would be able to say for Index 1 of my first table, match that to Index 1 of the Measure Table. The whole intent of this execise is to align each unique measure to the particular row so that I can then proceed to carry out more "normal" tabular calculations like sums, divides, multiplies, etc.
Am I missing something?
- Greg_Deckler6 years agoCommunity Champion
Anonymous - It's very difficult to say how this would work in your situation without seeing 1. Sample data and 2. Expected output from sample data.
Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490