Forum Discussion
Anonymous
9 years agoNot applicable
How to create reusable function
Hello, I would like to create a reusable function and I cannot find a way to do that. Is it even possible? Here is my use-case. I have several columns e.g., "Score A" and "Score B" with scores th...
- Anonymous9 years ago
Eventually I created an M function following the tutorial here.
Anonymous
9 years agoNot applicable
unpivoting will not work because the columns are claculated columns. Invoking the custom function also works only on the edit query level thus no chance to do it if the score is a calculated column.
v-chuncz-msft
Community Support
9 years agoAnonymous,
Instead of calculated column in DAX, you could add column in Query Editor as well.
- Anonymous9 years agoNot applicable
Yes you are right but DAX is much simpler than M when it comes to complex functions, even not so complex, simple if statements, or a SWITCH in M is alsmost impossible to do.
In my case the score that I want to calculate is a logarithm based on values of other columns. Anyways thanks for helping!
- v-chuncz-msft9 years ago
Community Support
Anonymous,
You may use the GENERATE Function similar to the CROSS APPLY condition in SQL.
Table = GENERATE ( X, UNION ( ROW ( "Attribute", "Score A", "Value", X[Score A] ), ROW ( "Attribute", "Score B", "Value", X[Score B] ) ) )