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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
MSuser5
Helper III
Helper III

MDX Query

Hi Team,

 

I would like to calculate sum of value by excluding 'null' values in the column, I have tried in SSAS cube-new MDX as like below but the sum result is wrong instead of 9845  result is : -5662 (coming as negative and wrong value)

my MDX (sum of wait time in minutes) : (sum([Measures].[Wait Time In Sec])/sum([Measures].[Total]))/60

 

kindly suggest or correct me where i missed .

 

Thanks,

 

1 ACCEPTED SOLUTION

Thanks @cpwebb ,

 

I have used SUM(coalesceEmpty([Measure].[waitTimeInSec],0)) and it's working fine.

View solution in original post

9 REPLIES 9
cpwebb
Microsoft Employee
Microsoft Employee

I don't think the nulls are the problem - I don't see how they would result in a negative value here. What type of aggregation is your waitTimeInSec measure using? As I said, if you have already built a measure then writing something like sum([Measures].[Wait Time In Sec])  is redundant and [Measures].[Wait Time In Sec] should give you the same incorrect result.

Hi @cpwebb ,

 

i too wondering about result eventhough [Wait Time In Sec] is int datatype and i created only one measure which is used sum function.

sum([Measures].[Wait Time In Sec])

 

Thanks,

cpwebb
Microsoft Employee
Microsoft Employee

In MDX (I assume you're using SSAS Multidimensional) using the SUM function with a measure in the way you're doing here doesn't actually have any effect - the default aggregation behaviour of the measure will be used. So using the following MDX in a measure:

([Measures].[Wait Time In Sec]/[Measures].[Total])/60

should give you the same incorrect result. What's more, MDX automatically ignores null values while aggregating anyway. Can you provide more details - with sample data - of what you want to do here?

 

More complex aggregation behaviour is possible using SCOPE statements. The following blog post might help:

https://blog.crossjoin.co.uk/2013/05/29/aggregating-the-result-of-an-mdx-calculation-using-scoped-as...

 

Chris

 

hi @cpwebb ,

 

yes i'm using SSAS multidimentional table here i tried to create new calculated measure like below 

 

MDX (sum of wait time in minutes) : sum([Measures].[Wait Time In Sec])

here is my table:

Wait Time In SecTotal
588965568
566894869
NULL9562
963477856
775464489
NULL8965
896477854

 

Expected total  of waitTimeInSec = 379125

 

i'm not sure may be due to NULL values result is coming : -266545 ( as negative)

 

kindly suggest how to create measure with replacing NULL values as 0  and sum of total.

 

Thanks,

MS

cpwebb
Microsoft Employee
Microsoft Employee

Is waitTimeInSec itself a calculated measure? If so, what is the definition? I don't think the nulls are the problem here.

 

Chris

Hi @cpwebb ,

i have created measure in SSAS Cube level referring fact table column  (which is waitTimeInSec)

so the measure result while SUM appear wrongly as negative total. Is this because of NULL on that column?

 

MS

cpwebb
Microsoft Employee
Microsoft Employee

Like I said, I don't think the nulls are the problem. You will need to provide a lot more detail on your cube design (please post screenshots of all relevant properties etc) in order to troubleshoot this.

Hi @cpwebb ,

 

Sure let me do deep analaysis on this issue and will share the details soon.

Thanks for your prompt response.

 

Regards,

MS

Thanks @cpwebb ,

 

I have used SUM(coalesceEmpty([Measure].[waitTimeInSec],0)) and it's working fine.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.