The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello guys, how to do this Excel VBA equivalent in PowerBI.
Function cust(mser, rratio)
Sum = 0
For n = 0 To mser - 1
Sum = Sum + rratio ^ n / FACT(n)
Next n
Sum = Sum + rratio ^ mser / FACT(mser) / (1 - rratio / mser)
cust = 1 / Sum
End Function
I am trying to do a some interactive model in which above function will be used as a measure. User will set the parameters and certain calculation will be done based on the user input. following is the screenshot. I am trying to do a calculation for "cust" using the function above
Pls help....
It looks like your function is describing a factorial function. If n =5, you want the function to return 120 (1 * 2 * 3 * 4 * 5).
Use the DAX function FACT().
Documention is available here
Thanks you Chris, I understand what you mean, I just wrote it as an example. I want a finction to do some thing similar to that, for an example another function will be like this....
Function cust(mser, rratio)
Sum = 0
For n = 0 To mser - 1
Sum = Sum + rratio ^ n / FACT(n)
Next n
Sum = Sum + rratio ^ mser / FACT(mser) / (1 - rratio / mser)
cust = 1 / Sum
End Function
you can think some solution for this?
You can use GENERATESERIES() to create a table of values, and then pass that into ADDCOLUMNS() to create some additional columns that could access those values and perform some sort of calculation on them.
Finally passing this table into a SUMX() or AVERAGEX() would convert the table into a single scalar value.
I think your request is still a little vague, are you able to share what your use case is?
DAX doesn't really support recursive functions. M can do a little recursion, but it involves List.Generate(), which is involved.
Thanks Again, I am trying to do a some dynamic model, where user will set the parameters and certain calculation will be done based on the user input. following is the screenshot. I am trying to do a calculation for "cust" using the function above
Function cust(mser, rratio) Sum = 0 For n = 0 To mser - 1 Sum = Sum + rratio ^ n / FACT(n) Next n Sum = Sum + rratio ^ mser / FACT(mser) / (1 - rratio / mser) cust = 1 / Sum End Function
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
94 | |
85 | |
69 | |
65 |
User | Count |
---|---|
244 | |
127 | |
119 | |
81 | |
78 |