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
GilesWalker
Skilled Sharer
Skilled Sharer

Table not calculating total correctly

Hi everyone,

 

I have created a number of measures to calculate something called NTK. What I am capturing is the kilometers travelled from one location to another and the total net tonnes.

 

The table I am using is called Consignments.

 

The kilometers is calculated using the following measure:

 

Kilometers = DIVIDE(SUM(Consignments[NewColumn.distance]),COUNTA(Consignments[Wagon type]))

 

The distance is divided my the count of wagon type because I need to know what the single distance travelled was. In our system each wagon type will have a distance registered to it. For example distance between point A and point B is 20km, if there are 10 wagons then each wagon has travelled 20km, total 200km, i.e 200/10 = 20km.

 

Next I used the follwoing measure to calculate the train load:

 

Train load = sumx(SUMMARIZE(Consignments,Consignments[Consignment_Id],Consignments[Tonnes]),Consignments[Tonnes])

 

 To calculate the NTK i created another measure:

 

New NTK = [Kilometers]*[Train load]

 

The issue I am having is that the individual routes are calculating correctly, but the total is not adding everything up. See the picture below:

 

NTK.PNG

 

The total for NTK should say 38,864,935.02 

 

The totals for Train load and Kilometers is also wrong. The total in each row is correct, just not the subtotal at the bottom.

 

I am hoping someone can tell me what I have done wrong so I have the totals calculated correctly.

 

Thanks,

 

Giles

 

 

1 REPLY 1
ImkeF
Super User
Super User

Looks like HASONEVALUE would work for you here: http://exceleratorbi.com.au/sum-vs-sumx-in-dax/

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.