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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chris12
Advocate I
Advocate I

User-defined functions in DAX?

Hi, this is a general question about the DAX language as I can use it in Power BI:

 

Can I, as a user, define/create/reuse new functions in a Power BI report? I'm often in the situation that parts of several measures could be abstracted into a shared function. This is easy to do in M (Power Query) but I don't see any way to do this in DAX.

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Chris12

 

It seems that we cannot define a reusable dax expression in Power BI currently. 

 

You could vote this idea here which has been submitted in Power BI ideas forum and add your comments there to improve Power BI and make this feature coming sooner.

 

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
garythomannCoGC
Impactful Individual
Impactful Individual

Custom (Reusable) DAX Function   please vote :}

Anonymous
Not applicable

Just as a reference, if anyone searches for this problem and comes to this post as I did..

my way of simulating this kind of functions is creating DAX measures always using variables like that:

CustomColumn =
// define the parameters and where to get their values
var param_startdate = related('abc'[abc])
var param_enddate = 'xyz'[xyz]
// the actual function goes here
return datediff(param_startdate,param_enddate,MINUTE)



that way I created a little library for my own reference where I can quickly find such functions and can easily reuse them.

Thanks.  However, do I understand correctly that the reuse happens via copy & paste?

Anonymous
Not applicable

Unfortunately yes, thats true. From a code maintenance perspektive that is a bad practise, I know. But its the only solution I can imagine for using standardized custom dax formulars with parameters.

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Chris12

 

It seems that we cannot define a reusable dax expression in Power BI currently. 

 

You could vote this idea here which has been submitted in Power BI ideas forum and add your comments there to improve Power BI and make this feature coming sooner.

 

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.