Skip to main content

Power BI

Under Review

Custom (Reusable) DAX Function

Vote (718) Share
Omaer Khan's profile image

Omaer Khan on 01 Mar 2017 02:06:50

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.

Comments (59)
Omaer Khan's profile image Profile Picture

Gabriel on 05 Jul 2020 23:33:53

RE: Custom (Reusable) DAX Function

Copy-paste waste my time and it's hard to maintain a bunch of duplicate dax code.

Omaer Khan's profile image Profile Picture

Danny on 05 Jul 2020 23:30:25

RE: Custom (Reusable) DAX Function

Code reuse is basic

Omaer Khan's profile image Profile Picture

Power BI User on 05 Jul 2020 23:30:24

RE: Custom (Reusable) DAX Function

Yes that is required

Omaer Khan's profile image Profile Picture

Neil MacMullen on 05 Jul 2020 23:29:30

RE: Custom (Reusable) DAX Function

Somewhat flabbergasted that this doesn't appear to be supported.

Omaer Khan's profile image Profile Picture

Power BI User on 05 Jul 2020 23:26:58

RE: Custom (Reusable) DAX Function

Agree !
basic and super powerful.

PBI TEAM - pls. add this

Omaer Khan's profile image Profile Picture

Power BI User on 05 Jul 2020 23:11:54

RE: Custom (Reusable) DAX Function

Completely agree. This would save so much development effort!!!

Omaer Khan's profile image Profile Picture

Power BI User on 05 Jul 2020 23:05:33

RE: Custom (Reusable) DAX Function

UDF is a basic concept of any programming language

Omaer Khan's profile image Profile Picture

schanuleke on 05 Jul 2020 23:04:56

RE: Custom (Reusable) DAX Function

Yes, we absolutely need this.

Omaer Khan's profile image Profile Picture

Jacob J. Walker on 05 Jul 2020 22:52:29

RE: Custom (Reusable) DAX Function

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.

Merged Idea (1)