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
Fgcillian
Frequent Visitor

Apply a DAX expression stored in a table

I'm struggling with an requirement and I don't really know if it can be done in Power BI.

 

Requirements: 1)DAX expressions will be stored in a column within a table imported in the data model of PBI.
2) Dinamically a Mesaure within Power BI should take the DAX expresion stored and apply it.

 

I attach a small example of what I´m trying to do.

  • From Data table (Data):
CustomerData
CLIENT1145
CLIENT154
CLIENT1777
CLIENT112
CLIENT155
CLIENT1888
CLIENT112

 

  • I need to apply the DAX expression stored in the following table (Expression):
CustomerExpression
CLIENT 1MAX(Data[Data])

 

For that, I'm creating a Measure that applies the expression using the CALCULATE function:

MAX_FROM_TABLE =
VAR _evalExpression = (ALL( 'EXPRESSIONS'[Expression] ))
RETURN
CALCULATE(_evalExpression)

 

The calculate returns the stored DAX but do not applies the formula:

Fgcillian_0-1674560396044.png

Is this possible with DAX? Which expression should I use?

 

Any help would be appreciated thanks.
Greetings from Spain.

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Fgcillian 

According to your description, you want to put a DAX expression in a table and then use a function to call the field.

According to my research, this is currently not possible in Power BI, and there is currently no function in the DAX function that can call text text to run expressions.

For your stored "MAX(Data[Data])", stored in Power BI is just a normal string format, so whatever formula is used, a string literal is returned.

 

With Measure, what is stored is really just a formula, which is only calculated when it needs to be calculated. For your different needs, you can try to create multiple measures or use some conditional judgment functions to meet your different needs.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @Fgcillian 

According to your description, you want to put a DAX expression in a table and then use a function to call the field.

According to my research, this is currently not possible in Power BI, and there is currently no function in the DAX function that can call text text to run expressions.

For your stored "MAX(Data[Data])", stored in Power BI is just a normal string format, so whatever formula is used, a string literal is returned.

 

With Measure, what is stored is really just a formula, which is only calculated when it needs to be calculated. For your different needs, you can try to create multiple measures or use some conditional judgment functions to meet your different needs.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Thanks Aniya for your feedback. 

It's clear now.

 

Best regards,

Cillian

amitchandak
Super User
Super User

@Fgcillian , Try like

 

calculate(MAX(Data[Data]), all())

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.

Top Solution Authors