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
JKoivu
Helper I
Helper I

Simple calcuation behaves oddly

Hi, I have a measure DAX similar to this example:

Distance exceeded =
VAR distance = MAX(MyTable[Distance from previous])
VAR maxDistance = [Max distance]
VAR fraction = distance / maxDistance
RETURN fraction > 1

I tried putting this measure to my table visual, but the results don't make sense to me. For example, if on that row distance = 15000 and maxDistance = 10000 and I do RETURN fraction, I get 1.5 on the table. This fraction value looks ok on every row. But if I do RETURN fraction > 1, the table shows FALSE for every row, even if the fraction is actually >1. Other observation is that if I try to do RETURN fraction + 1, the table always shows 1.00.

What could be causing this behaviour? I would expect that if for example value of fraction variable is 2.3 and I do RETURN fraction + 1, table would show 3.3. I've tried to use CONVERT and ROUND everywhere but that doesn't seem to make any difference.

 

1 ACCEPTED SOLUTION

Hi. Yes my issue is resolved, the reason was that there was a very obvious calculation error in my measure, which I failed to notice due to time pressure. Also the reason I was getting weird values for the calculation was because I put this measure in a table (for debugging purpose), and that messed up the context. So basically my whole question is not really valid...

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @JKoivu

 

Is  your issue solved?

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi. Yes my issue is resolved, the reason was that there was a very obvious calculation error in my measure, which I failed to notice due to time pressure. Also the reason I was getting weird values for the calculation was because I put this measure in a table (for debugging purpose), and that messed up the context. So basically my whole question is not really valid...

Hi @JKoivu

 

Glad to hear that,could you pls mark the reply as answered to close it?

 

Much appreciated.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
amitchandak
Super User
Super User

@JKoivu , You need to correct your return statement

 

Distance exceeded =
VAR distance = MAX(MyTable[Distance from previous])
VAR maxDistance = [Max distance]
VAR fraction = distance / maxDistance
RETURN if( fraction > 1,[fraction]+1,[fraction])

Fowmy
Super User
Super User

@JKoivu 

I am not reading the logic here, are you trying to get something like this. Can you explain your desired results if this is not the solution?

Distance exceeded = 
VAR distance = 15000//MAX(MyTable[Distance from previous])
VAR maxDistance =  10000 //[Max distance]
VAR fraction = distance / maxDistance
RETURN 
if(fraction > 1 , fraction + 1, fraction)

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.