This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello all,
I have been pulling data via odata and been trying to calculate percentages within my query
The code is as follows:
&"aggregate("
&"$count as TotalCount,"
&"cast(LastResultOutcome eq 'Passed', Edm.Int32) with sum as PassedCount,"
&"cast(LastResultOutcome eq 'Failed', Edm.Int32) with sum as FailedCount,"
&"cast(LastResultOutcome eq 'None', Edm.Int32) with sum as NotRunCount,"
&"cast(LastResultOutcome ne 'None', Edm.Int32) with sum as RunCount"
&")"
&")"
&"/compute("
&"RunCount div TotalCount as RunPercentage,"
&"NotRunCount div TotalCount as NotRunPercentage,"
&"iif(TotalCount gt NotRunCount, PassedCount div RunCount,0) as PassedPercentage,"
&"iif(TotalCount gt NotRunCount, FailedCount div RunCount,0) as FailedPercentage"
&")"
&"&$orderby=RunPercentage desc", null, [Implementation="2.0"])however, these are my results:
TotalCount PassedCount FailedCount NotRunCount RunCount RunPercentage NotRunPercentage PassedPercentage FailedPercentage
63 21 0 42 21 0 0 1 0
was wondering why the percentage fields are returning either 0 or 1. Hope someone can help me out here
Solved! Go to Solution.
Hi @ak105
The results are correct because both dividend and divisor are Integers. When you use div or /, it returns the data type of the argument with the higher precedence. For more information, see Data Type Precedence (Transact-SQL). If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated. Reference: / (Division) (Transact-SQL).
To have the percentage fields return decimal numbers, you can convert the dividends or divisors to float or decimal data types.
Data type conversion (Database Engine)
CAST and CONVERT (Transact-SQL)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Thank you! This helps!
Hi @ak105
The results are correct because both dividend and divisor are Integers. When you use div or /, it returns the data type of the argument with the higher precedence. For more information, see Data Type Precedence (Transact-SQL). If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated. Reference: / (Division) (Transact-SQL).
To have the percentage fields return decimal numbers, you can convert the dividends or divisors to float or decimal data types.
Data type conversion (Database Engine)
CAST and CONVERT (Transact-SQL)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 3 | |
| 3 | |
| 3 |