Forum Discussion
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.
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...
5 Replies
- FowmySuper 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 🙂
- amitchandakSuper 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]) - v-kelly-msftCommunity Support
Hi JKoivu ,
Is your issue solved?
Best Regards,
KellyDid I answer your question? Mark my post as a solution!- JKoivuHelper I
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...
- v-kelly-msftCommunity Support
Hi JKoivu,
Glad to hear that,could you pls mark the reply as answered to close it?
Much appreciated.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!