Skip to main content

Power BI

Under Review

Custom (Reusable) DAX Function

Vote (730) 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 (61)
Omaer Khan's profile image Profile Picture

Roy Wells on 05 Jul 2020 23:34:47

RE: Custom (Reusable) DAX Function

Yes to this. Huge issue on large models with many similar complex measures

Omaer Khan's profile image Profile Picture

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

RE: Custom (Reusable) DAX Function

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

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.

Merged Idea (1)