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
Anonymous
Not applicable

SUM of a measure

Hi!

 

I have a problem considering calculating the sum of a measure. I have seen the problem in other posts but haven't been able to make the suggested solutions work in my report.

 

Visualisation.PNG

 

  • Car-ID (name of the car)
  • Route-ID (name of the route the car drives)
  • Driving Cost (driving cost per route)
  • Total Cost (driving cost per route multiplied by the number of times each car takes the particular route

In the visualization above the values are shown for one Car-ID and several routes which also occur several times, hence the multiplication to calculate Total cost.

 

Driving cost and Total driving cost are measures whereas the Car-ID and Route-ID are found in two separate tables and related to each other.

 

I need the total that is highlighted to show the sum of the rows above (32100) as is done in the Driving Cost-column. For the rows everything works correctly.

 

In DAX i have the following:

 

Driving Cost =SUM('Routes'[Cost per route])
 Total Cost = [Driving Cost]*count('Routes'[Route-ID])

Appreciate all help!

3 REPLIES 3
Arul
Super User
Super User

Hi @Anonymous 

For calculating total cost you need to create new calculated column and it automatically summarize the total value as a sub-total. You don't need create any measure for this to sum.

 

FORMULA FOR CREATING NEW CALCULATED COLUMN:

NEW CALCULATED COLUMN=

[Driving Cost]*number of times each car takes the particular route

Here you don't need to count the route id, you need to multiply it by number of times that the car takes on the particular route.

 Hope you get my point.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Anonymous
Not applicable

Hi @Arul !

 

Thanks for your tip. I've tried creating a calculated column in my table containg information about the cars. However, I still get the wrong sum for the cars and they are still calculated as in my first post.

 

This was the formula I entered for the calculated column:

Total Cost = [Driving Cost] * COUNT('Cars and Routes'[Route-ID])

The Cars nad Routes table contains one clumn for the car and another column for the routes where one route can exist several times per car as well as for other cars, hence the count in the formula above.

 

 

Below is my measure for the driving cost. The calculations for this one is correct as they are shown in the table in my first post but perhaps it affects the calculation for the total cost.

Driving Cost = CALCULATE(SUM('Routes'[Cost per Route]);CROSSFILTER('Cars and Routes'[Route-ID];'Routes'[Route-ID];both))

Thanks!

 

Hi @Anonymous 

Can you share your pbix file, because it will helpful for me to sort out your problem.

 

Thanks & regards,

-Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


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.