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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
android1
Post Patron
Post Patron

Divide sum of one column by the count of another

Hi,

 

I have a column LoS which is in number format with a sum total. The other column, ID, is a Count of text values.

 

Is it possible to divide LoS by ID?

 

Gerry

2 ACCEPTED SOLUTIONS
malagari
Responsive Resident
Responsive Resident

Sure - you can do this as a DAX measurement.  Unless I'm misunderstanding your post, it should be simple as:

 

Measure = LoS / ID

And if you're worried about the possibility that 'ID' will be zero, you want to account for the divide-by-zero case with:

Measure = DIVIDE(LoS, ID, 0)


However, if you need the aggregations (sum of LoS, count of ID) done in the measurement:

 

Measure = DIVIDE( SUM(LoS), COUNT(ID), 0 )

 

 And alternately, if the ID is text values, you can use COUNTROWS(ID) instead.

Dan Malagari
Consultant at Headspring

View solution in original post

So make sure you click the "New Measure" button on the modelling tab.

 

or right click the table name and choose "New Measure" and add the above code by @malagari

 

Measure = DIVIDE( SUM(LoS), COUNT(ID), 0 )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
malagari
Responsive Resident
Responsive Resident

Sure - you can do this as a DAX measurement.  Unless I'm misunderstanding your post, it should be simple as:

 

Measure = LoS / ID

And if you're worried about the possibility that 'ID' will be zero, you want to account for the divide-by-zero case with:

Measure = DIVIDE(LoS, ID, 0)


However, if you need the aggregations (sum of LoS, count of ID) done in the measurement:

 

Measure = DIVIDE( SUM(LoS), COUNT(ID), 0 )

 

 And alternately, if the ID is text values, you can use COUNTROWS(ID) instead.

Dan Malagari
Consultant at Headspring

Thanks alot. What I was doing wrong was I had the result to display in a KPI visual rather than a Card so I thought LoS / ID wasn't correct.

 

Thanks again.

So make sure you click the "New Measure" button on the modelling tab.

 

or right click the table name and choose "New Measure" and add the above code by @malagari

 

Measure = DIVIDE( SUM(LoS), COUNT(ID), 0 )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.