cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Varshada
Frequent Visitor

Measure Calculation based on Dynamic DAX Formulae stored as a part of table

Hi Everyone,

 

We are working on P/L and Financials reporting in power bi  and have lot of derived measures whose definitions are bound to change on frequnent basis based on User requirement. Hence planning to keep the dax formula dynamic.

 

We could manage dynamic row addtions using "SWITCH" and Variables. But when we try to retrieve the formulae stored in a table against every "Account Name", it returns literal string rather that evaluating the formula.

 

Any help is appreciated.

 

Scenario:

Account (Dimension):

Varshada_0-1617272274562.png

 

Elimination (Fact):

Varshada_1-1617272315786.png

Fact (Fact):

Varshada_2-1617272354656.png

 

Measure Table:

Value = SUM('Fact'[Amount]) + SUm(Elimination[Elimination])
Margin = CALCULATE(sum('Fact'[Amount]), FILTER(all('Account'),'Account'[Account Name]="Sales")) - CALCULATE(sum('Fact'[Amount]), FILTER(all('Account'),'Account'[Account Name]="Cost")) -CALCULATE(sum('Elimination'[Elimination]), FILTER(all('Account'),'Account'[Account Name]="Elimination"))
Amount Derived 1 =
Var A = IF(HASONEVALUE(Account[Account Name]),VALUES(Account[Account Name]),BLANK())
RETURN
SWITCH(A,"Margin",[Margin],[Value])
 
Results expected:
Varshada_3-1617272499692.png

Requirement : In the above table visual, we need the "Amount Derived 1" measure to dynamically calculate the value from the stored DAX expression or the [Table].[column] set up in Account Dimension.

 

Thanks,
Varshada
 

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Varshada ,

 

Unfortunately, formulas stored in tables cannot be switched, but measures can be changed dynamically based on the current row context.

See if it will help:

https://community.powerbi.com/t5/Community-Blog/Using-a-slicer-to-show-different-measures/ba-p/17245... 

 

Best Regards,
Liang
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
lbendlin
Super User III
Super User III

If you want to see progress you may want to vote for an existing idea or create a new one.

TWF2021
Regular Visitor

Hi,

 

This is the exact same problem I've been having with something i'm working on. I want to be able to dynamically pick up the DAX formulae from the tables in the load and haven't found a way of being able to pick up the string and execute it. Like you, i've just ended up seeing the string.

 

I was hoping there might be a way that one could change the definition of measures during the load phase, but it seems there isn't. If anyone finds a way it would be good to hear it!

V-lianl-msft
Community Support
Community Support

Hi @Varshada ,

 

Unfortunately, formulas stored in tables cannot be switched, but measures can be changed dynamically based on the current row context.

See if it will help:

https://community.powerbi.com/t5/Community-Blog/Using-a-slicer-to-show-different-measures/ba-p/17245... 

 

Best Regards,
Liang
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

Thanks Liang, we have tried this alternative which makes us create those many measures and switch them on user input..was looking more from maintaining the DAX in table and picking it dynamically.

 

lbendlin
Super User III
Super User III

EVALUATE() is only available in external tools like DAX Studio.  You cannot do that in Power BI Desktop DAX (yet).

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Kudoed Authors