cancel
Showing results for
Search instead for
Did you mean:
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):

Elimination (Fact):

Fact (Fact):

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:

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
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:

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

5 REPLIES 5
Super User III

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

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!

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:

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

Frequent Visitor

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.

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

Welcome to the User Group Public Preview

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

Microsoft Business Applications Summit sessions

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

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors