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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ckolahi
Frequent Visitor

Create a calculated column actuals vs Budget

  • Hi PBI experts.

I am new here and starting with PBI so apologies in advance if the question is stupid.

 

I have a situation. Here is the table, the columns in black are the ones I have and I need to create a calculated column (in red) showing a target achievement per reps (as decribed in the table below). 

 

As anyone have an idea if its possible ?  Thank you in advance for your help

 

ckolahi_1-1661172050429.png

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@ckolahi Assuming a Status of A is actuals and B is budget, maybe:

% Achievement Column = 
  VAR __Name = [Name]
  VAR __Measure = [Measure_SIP]
  VAR __Status = [Status]
  VAR __Month = [Month]
  VAr __Year = [Year]
RETURN
  IF(
    __Status = "B",
    0,
      VAR __Actual = IF(__Measure = "Net Sales USD", [Net_Sales_USD], [Units])
      VAR __Table = FILTER('Table',[Name] = __Name && [Measure_SIP] = __Measure && [Status] = "B" && [Month] = __Month && [Year] = __Year)
      VAR __Budget = IF(__Measure = "Net Sales USD", MAXX(__Table, [Net_Sales_USD]), MAXX(__Table, [Units])
    RETURN
      DIVIDE(__Actual, __Budget, 0)
  )

That said, I think you should look into unpivoting your Net_Sales_USD and Units columns and this would likely be a far easier calculation.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@ckolahi Assuming a Status of A is actuals and B is budget, maybe:

% Achievement Column = 
  VAR __Name = [Name]
  VAR __Measure = [Measure_SIP]
  VAR __Status = [Status]
  VAR __Month = [Month]
  VAr __Year = [Year]
RETURN
  IF(
    __Status = "B",
    0,
      VAR __Actual = IF(__Measure = "Net Sales USD", [Net_Sales_USD], [Units])
      VAR __Table = FILTER('Table',[Name] = __Name && [Measure_SIP] = __Measure && [Status] = "B" && [Month] = __Month && [Year] = __Year)
      VAR __Budget = IF(__Measure = "Net Sales USD", MAXX(__Table, [Net_Sales_USD]), MAXX(__Table, [Units])
    RETURN
      DIVIDE(__Actual, __Budget, 0)
  )

That said, I think you should look into unpivoting your Net_Sales_USD and Units columns and this would likely be a far easier calculation.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  thank you very much it works

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.