Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

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.
Status: Under Review
Comments
Mousavi_sajjad
New Member

More that 5 years and still UNDER REVIEW?! Seriously?! Hurry up Microsoft! You should act before even people think about it! This is a VERY BASIC feature. QBasic had it 20 years ago!

v-Rafal_Monka
New Member

Dear Microsoft Power BI Team,

every serious developer working with DAX code will say that this feature is a must be.

The question is when Custom functions will be available?

ARU1
New Member

All we need are UDF to return results. I get they will need context but it will save ALOT of coding hrs is to be able to do something like:


IF(A, Function(param),

IF(B,Function(param),

etc....

nishalit
New Member
Would be useful if you had the ability to create your own DAX functions that allows for variables to be inserted into the function. I find that quite often I require a Base Measure that only subtly needs changing. Eg, Groups by a different dimension in a SUMMARIZE formula, or alternately uses a different SUM measure to produce a different result with the same manipulation of the rest of the DAX Formula. This will allow for the Base Measure to be adjusted if a more effective solution emerges, rather than requiring a change for every single measure that the function has been applied to.
8018616
New Member

Please implement this!!! I waste so much time copy/pasting similar code, which could be fixed by creating a custom reusable function with passthrough variables...

rodolfo_c1
New Member

Please implement this feature.

This is a must! for a serious programing language.

Thanks.

xavier_arnoux
New Member

Hi,


I have dax code with 35 lines for each kpi and I don't understand that "personal function" is not yes implemented in Power BI ! So I have to duplicate this code for more than 50 KPI !!!


When could you answer at this lack ?

Keith_Dunn
New Member

IMHO, this is nothing but a Calculation Group that is applied to a measure by default at the measure level as opposed to being applied globally to all selected measures manually using a filter. That seems an easy addition. Calculation Groups are really just repetitive calculations that pass in an input measure using SELECTEDMEASURE. Despite the use case that everybody demonstrates, they are not just intended for time intelligence calculations.

KaydenKH_LIM
New Member

Unforgiveable that this has yet to be implemented, no wonder powerBI is not even more popular than it should be

jhowell1
New Member

Yo MS Team - it's April 2023. Ping.