powerbidaxpowerquerypowerpivot

How to create a DAX formula to create another column based on the value in another column


How do I create a formula in Dax that gives me the % achieved column, based on the location. When it is EU the % achieved formula should be actual*target else it should be actual+target

More background info: The actual is in a different dataset and target is also in another. Data modeling relationships created to link them together Tried using IF but getting error

Actual Dataset

Name Location Actual
John EU 10
John ASIA 4
Steve EU 5
Steve ASIA 87

Target Dataset

Name Location Target
John EU 5
John ASIA 5
Steve EU 7
Steve ASIA 9

View when relationships created on name and location. The new measure should give the % Achieved column

Name Location Actual Target % Achieved
John EU 10 5 50
John ASIA 4 5 9
Steve EU 5 7 35
Steve ASIA 87 9 96

Solution

  • enter image description here

    Measure = IF(SELECTEDVALUE('Table'[Location])="EU", SUM('Table'[Actual]) * SUM('Table'[Target]), SUM('Table'[Actual]) + SUM('Table'[Target]))