cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FehrOne
New Member

Simple DAX formula to state the Goal from a table

capture1.JPGcapture2.JPG

I am new to DAX so my apologies for the basic question....

How can I get the Goal % column to reflect what I have listed in my table?
My table is for Customer and what I think the Goal % should be.

The Customer fields are connected in my Model.

I just want the Goal % to say what I have in my table (for each Customer).

Seems like it should be very simple but I cannot figure it out

 

 

3 REPLIES 3
kentyler
Solution Sage
Solution Sage

You did not post any actual data samples... so it's hard to really say.

but looking at your DAX measure my guess would be that when you take the AVG of the Goal table it is already being filtered by the external context... so you do not get the number you think you should get.

You probably need to use CALCULATE with the ALL function to restore the full table to do the average over.

Goal % = CALCULATE(AVERAGE('Table'[Goal])/100,ALL(Table))
depending on whether you need to remove the filter context for the whole table, or possible just for the Goal column, in which case it would be ALL(Table[Goal])

I'm a personal Power Bi Trainer I learn something every time I answer a question

The Golden Rules for Power BI

  1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
  2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
  3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.




Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Thank you so much for the reply!  I am not sure the AVERAGE function is what I need.

Capture4.JPG

I have the Goal % (for each customer) in a table.  I am looking for a way to get the straight number from the table into my visual.

 

Right now, the only options are Sum, Avg, Min, Max, Count, etc.

 

capture3.JPG

I just want the exact value but cannot figure out how to do that.

 

capture2.JPG

If the percentage values are in a table, then you should be able to write a measure.

As you have discovered measures cannot address a column value directly, because a measure does not have a specific "row context"

But if you place your measure in the table control, then the table (or matrix) will generate a filter context that changes for each row.

You can address that filter context to get the percentage for the row

Percent Value = SELECTEDVALUE(mytable[percentColumn])

or something like that should work

SELECTEDVALUE

  • 12/09/2018
  • 2 minutes to read
      •  
     
    •  

Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult.

 
SELECTEDVALUE(<columnName>[, <alternateResult>])   

 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors