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

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

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.