Forum Discussion
MdxScript(Model)(17,3) calculation error
- 1 year ago
Yes, Int64 is the limit. Embarrassingly Power BI does not support Int128.
Have you tried the logarithm approach?
The Int64 limit was the blocker for what I was trying to do, however, researching and testing all of this, including the LN approach, exposed a couple of problems in the data.
The values of the column being evaluated are the result of a DATEDIFF function, getting to a number of days. While it is not the norm, it's possible that choosing DATEDIFF on DAY results in 0, if the start datetime is in the very early morning, and the end datetime is later in the evening approaching midnight. May 7 - May 7 is 0.
To avoid operating on zeros, which causes errors, I modified the DATEDIFF to operate on MINUTE, then divided that result by 60 to get an hour span which is needed for another calculation, and then divided it further by 24 to get a day span which would give those not quite a full 24-hour span a decimal value result, eg. 20 hours of 0.833333. That solved the 0 problem.
I still got an error despite that cleanup with some outlier cases - and discovered a data quality issue where a datetime of say 2025-05-07 23:59 on one table, somehow got recorded in a second location (after systemic processing) as 2025-05-07 00:00. Note it didn't flip the day to 2025-05-08, I had a start datetime of 2025-05-07 07:41, but then an end datetime of 2025-05-07 00:00, impossible to end before you began.
A change in where that end datetime was pulled removed those outliers (along with some error checking just in case it would slip in again) led to an accurate positive non-zero result in the SQL calculation for that column.
Once all that was done, GEOMEAN() worked as intended without having to convert to log values, apparently the Int64 limit doesn't apply to it's own internal calculations, because the product did exceed Int64 in some cases.
All in all, a better outcome to be able to use the built-in function rather than recreating it, and taught me to double check my input values earlier in the troubleshooting process.