cancel
Showing results for
Did you mean:
Helper I

## Dynamic Calculated Measure

Hi,

I have two tables below one from salesforce - opportunity and one from excel

I wanted to create a dynamic measure base on a slicer which will be from the excel table and multiply the value to the opportunity table

so for example, if the slicer is set to commodities at 2/5/2021 then I want the equation for 2021 assumption to multiply the filtered values :

if ('Opportunity'[Commit_Upside__c] = "Booked", 'Opportunity'[ToUSD-Positive-License_Cost__C] * sum('2021-Assumptions'[Booked%]),
if ('Opportunity'[Commit_Upside__c] = "Commit", 'Opportunity'[ToUSD-Positive-License_Cost__C] * sum('2021-Assumptions'[Commit%]),
if ('Opportunity'[Commit_Upside__c] = "Upside", 'Opportunity'[ToUSD-Positive-License_Cost__C] * sum('2021-Assumptions'[Upside%]),
if ('Opportunity'[Commit_Upside__c] = "Potential", 'Opportunity'[ToUSD-Positive-License_Cost__C] * sum('2021-Assumptions'[Potential%]),
if ('Opportunity'[Commit_Upside__c] = "Pipeline", 'Opportunity'[ToUSD-Positive-License_Cost__C] * sum('2021-Assumptions'[Pipeline%]), 0)
))))

Is it possible?

So far Ive gotten to

Division Factor =
VAR SelectedDivision = SELECTEDVALUE( '2021 Assumptions'[Division] )
VAR SelectedDate = SELECTEDVALUE( '2021 Assumptions'[Date] )
VAR myFilteredTable =
CALCULATETABLE(
'2021 Assumptions',
'2021 Assumptions'[Date] = SelectedDate,
'2021 Assumptions'[Division] = SelectedDivision
)
RETURN
SUMX( myFilteredTable, if (CALCULATETABLE(Opportunity,Opportunity[Commit_Upside__c]) = "Booked"), SUM('Opportunity'[Positive_Services_Amount__c USD]) * sum('2021 Assumptions'[Booked%]),
if (CALCULATETABLE(Opportunity,Opportunity[Commit_Upside__c] = "Commit"), SUM('Opportunity'[Positive_Services_Amount__c USD]) * sum('2021 Assumptions'[Commit%]),
if (CALCULATETABLE(Opportunity,Opportunity[Commit_Upside__c] = "Upside"), SUM('Opportunity'[Positive_Services_Amount__c USD]) * sum('2021 Assumptions'[Upside%]),
if (CALCULATETABLE(Opportunity,Opportunity[Commit_Upside__c] = "Potential"), SUM('Opportunity'[Positive_Services_Amount__c USD]) * sum('2021 Assumptions'[Potential%]),
if (CALCULATETABLE(Opportunity,Opportunity[Commit_Upside__c] = "Pipeline"), SUM('Opportunity'[Positive_Services_Amount__c USD]) * sum('2021 Assumptions'[Pipeline%]), 0)
))))

But this doesn't seem to work.

2 REPLIES 2
Super User

@powerbiwork First, use a SWITCH or SWITCH(TRUE()...) statement instead of IF statements. Second, seems like you would want to base that SWITCH statement on the value in your slicer, SelectedDivision

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Helper I

@Greg_Deckler  thank you I will give that a try.

Announcements

#### Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

#### European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

#### Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors