cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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):
 Customer Data CLIENT1 145 CLIENT1 54 CLIENT1 777 CLIENT1 12 CLIENT1 55 CLIENT1 888 CLIENT1 12

• I need to apply the DAX expression stored in the following table (Expression):
 Customer Expression CLIENT 1 MAX(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:

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

Any help would be appreciated thanks.
Greetings from Spain.

1 ACCEPTED SOLUTION
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

3 REPLIES 3
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

Frequent Visitor

Thanks Aniya for your feedback.

It's clear now.

Best regards,

Cillian

Super User

@Fgcillian , Try like

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

Announcements

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Power BI Monthly Update - May 2024

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

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors