Custom (Reusable) DAX Function
I'd like to be able to create reusable functions in DAX, instead of using the same DAX code in multiple measures.
Example: I have some complicated DAX code, which calculates the no of working seconds between two date-times. This excludes holidays, weekends, and only counts seconds from the start of the work-day, to the end of the work-day.
I use this DAX code a lot, for many measures which need to be in "Working Time" (working hours/minutes).
I would love to not have to copy-paste a bunch of code into all of my measures, but to be able to create a reusable function instead.
Juliusz Gonera commented
+1. I have a spreadsheet with only tens of custom measures and managing them all is already a nighmare.
Alex Eisenhart commented
This would be useful because I often need to do a linear interpolation in a measure with a What If Parameter, to shift between a min and max at a user-specified ratio. It's troublesome to repeat the linear interpolation formula and it would much easier if I could just create a Tween(min, max, ratio) function to leverage an abstract formula.
Would indeed be a big improvement for maintainbality and development time indeed. Im writing the same 2 formulas over and over, only difference are the ledger accounts that are being filtered.
It would be incredibly useful
Adam Estrada commented
Yes, please add to Power BI. This would end the long-winded DAX measures that are hard to read yet nonetheless critical for our company's reports.
Adding it to Excel's data model would be nice, too.
I agree wholeheartedly.
Why recreate the wheel every time you need one
Would be very useful and easier to do updates to a measurement (along with source control hopefully somewhere in the future)
Please update on this,
This will make power bi a power full tool.
need this ASAP
Any updates on this, Power BI Team? It's shocking that a product like this requires so much code duplication, it makes it so hard to maintain.
100% keen for this. Also would appreciate having a built-in solution for working time, was surprised to find that you have to write that yourself
Copy-paste waste my time and it's hard to maintain a bunch of duplicate dax code.
Code reuse is basic
Yes that is required
Neil MacMullen commented
Somewhat flabbergasted that this doesn't appear to be supported.
basic and super powerful.
PBI TEAM - pls. add this
UDF is a basic concept of any programming language
Yes, we absolutely need this.
Jacob J. Walker commented
It seems a no-brainer to have this capability, and is so weird that it appears that it doesn't (I've been trying to find a way of doing it for a bit now!). If DAX could have UDFs, it would be possible to start to build a library of data analysis functions that could rival R for data science applications. But without this expandability, it is not in as competitive of a position.