Forum Discussion

pbiXlsx's avatar
pbiXlsx
Frequent Visitor
3 years ago
Solved

Syntatic sugar wanted

Hi, 

 

how can I make this code better?

 

I am using this measure for a template approach. So I define the key for each line and calculate the value based on the key. 

 

I know i could make this by using a matrix, but the original template I have to built is way more complex and not that straight forward (so not only the account number is differing).

 

How can I write the code seen below better (by defining a variable and just changing the input in every line e.g.)

 

Thanks in advance!

  • You can't iterate over a changing variable, thats not how power bi works, it will take the variable once and calculate it and then use it for your script.  You would need to create a different variable for each line. 

1 Reply

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    You can't iterate over a changing variable, thats not how power bi works, it will take the variable once and calculate it and then use it for your script.  You would need to create a different variable for each line.