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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.