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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Arendp
Helper III
Helper III

sum divided by count

Hello I have a problem with a Dax calc.

Knipsel.PNG

I need to divide the sum of Metingtest 2 by count Metingtest. That results in Metingtest3. And that result is correct.

However in the bottom , you see 52488 .That is the result of the total divided by total count. (264382263/5037)

But I need to have the sum of Metingtest3 (so all results of that column summed up)

How can I accomplish that?

So calculation of Metingtest3 = sum(budgetrow)/Count(budgetrow)

 

Hopefully I am explaning myself in a good way... 🙂

1 ACCEPTED SOLUTION
JustJan
Responsive Resident
Responsive Resident

Hi @Arendp ,

 

I think it needs to be something like this: 

 

AvgRowAndTotal = 
// My Dummy MetingTest3Berekening = Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity]))
Var RowOrTotal =
IF ( ISFILTERED('Product'[Category]), -- replace Product[Category] with your own fields
Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity])),
SUMX(
Summarize ( -- create temporary table with the same subtotals
Sales, -- you can check them in DAX studio
'Product'[Category],
"rowtotal", Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity]))
)
, [rowtotal])
)
return RowOrTotal

Hope this helps, 

 

Jan 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

 

Are they columns or measure?

 

For column you have hasonevalue function.

 

There are more threads for total is wrong on community you can check those.

 

Thanks,

Pravin

 

 

JustJan
Responsive Resident
Responsive Resident

Hi @Arendp ,

 

I think it needs to be something like this: 

 

AvgRowAndTotal = 
// My Dummy MetingTest3Berekening = Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity]))
Var RowOrTotal =
IF ( ISFILTERED('Product'[Category]), -- replace Product[Category] with your own fields
Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity])),
SUMX(
Summarize ( -- create temporary table with the same subtotals
Sales, -- you can check them in DAX studio
'Product'[Category],
"rowtotal", Divide(sumx ( sales, Sales[Quantity] * Sales[Net Price]),sum(Sales[Quantity]))
)
, [rowtotal])
)
return RowOrTotal

Hope this helps, 

 

Jan 

That helped, thanks!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors