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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Formula to return value from a range will not work in a DAX measure, but works in a DAX Col

This is driving me nuts. I have never encountered this before.

I have a table (Excel Based called 'Metric Ranges' That contains a series of Metrics and their scoring range values (Lower Limit and Upper Limit).

Metric Ranges TableMetric Ranges Table

I need to create a measure that will pass in the the MetricId, and MetricValue into this table and return the score based on the ranges for the metric. The formula below works fine in a table column and returns the Score, but for some reason as a Measure, it will not return the value. When I test and return all the VAR's I get values returned, so I know it's not the values there, it is the actual Calculation and that is not working. The Score returned is a blank value.  Any ideas why this will not work?  

Forumla is:

Net Savings Year to date =

VAR MetricValue = [Savings % Annualize Goal]
VAR MetricPrgm = "4003"
VAR MetricId = 1

VAR Score =
CALCULATE
(
VALUES('Metric Ranges'[Score]), FILTER ('Metric Ranges', 'Metric Ranges'[MetricId] = MetricId && 'Metric Ranges'[Program] = MetricPrgm && MetricValue > 'Metric Ranges'[Lower Range] && MetricValue <= 'Metric Ranges'[Upper Range] )
)

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Anonymous I assume the "metric range" table is not having a relationship with any table? Correct?

 

Try changing Metric Range to ALL ( Metric Range) in the filter.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@Anonymous that seems to be the problem, as I mentioned use ALL and test it and then we can take it from there.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Anonymous good to know. Enjoy!!

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous that seems to be the problem, as I mentioned use ALL and test it and then we can take it from there.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous I assume the "metric range" table is not having a relationship with any table? Correct?

 

Try changing Metric Range to ALL ( Metric Range) in the filter.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

That's the ticket!   It worked.  

Anonymous
Not applicable

It has a relationship with the Calendar Table - Effective Data : Date

parry2k
Super User
Super User

@Anonymous can you share pbix file with the sample data? I'm assuming you checked the following var returning the value that falls between the range.

VAR MetricValue = [Savings % Annualize Goal]

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Because of company privacy I cannot share the .pbix file.   But, I can confirm that the measure returns a value.  In fact all the VAR's return values.  The Calculate is just not working in the measure, but it works when used in a Table Column.  

[Savings % Annualize Goal] does have a value.  If I switch the the 'Return' to [Savings % Annualize Goal] the value is returned. 
MeasureValueReturned.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.