Forum Discussion

Aaron197899's avatar
Aaron197899
Regular Visitor
4 years ago
Solved

SUM X

Hi, 

 

Hopefully someone can help with a question that is driving me mad, I have a table containing details of vehicle trips - Customer a to Customer b - within this table I also have the mileage for each individual trip

 

I need to be able to calculate the overall mileage for each trip perfromed by specified date parameters, I have used the below measure

 

Mileage By Customer = SUMX('Mileage & CO2','Mileage & CO2'[Mileage]) * [Total Jobs]
 
The mileage calculation works fine but the grand total is totally incorrect, I have found that the mileage column is being summed and the measure is then * this by the total of jobs giving me a figure that isnt reflective of the data within the individual rows.
 
Would anyone know how to create a measure to overcome this issue?
 
Thanks in adavnce for any help, 
 
Kind Regards, 
 
Aaron

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Aaron197899 ,

     

    A*C +B*D <> (A+B) * (C+D)

     

    See the differences:

    Measure = SUMX('Mileage & CO2',[Mileage]*[Total Jobs])
    Measure 2 = SUM('Mileage & CO2'[Mileage]) * SUM('Mileage & CO2'[Total Jobs])

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Aaron197899 , You should try multiplication at row level

     

    Mileage By Customer = SUMX('Mileage & CO2','Mileage & CO2'[Mileage] * [Total Jobs])

     

    if they are in different tables then use common dimensions or visual column

     

    example

    Mileage By Customer = SUMX(values(Dim[Column]), Sum('Mileage & CO2','Mileage & CO2'[Mileage]) * [Total Jobs])

    • Aaron197899's avatar
      Aaron197899
      Regular Visitor

      Hi Amitchandak, 

       

      Thank you for your help, 

       

      Apologies - relatively new to BI 

       

      It's the grand total that isnt calculating correctly - the rows are fine but the total is mulitplying the "total jobs" by the summed mileage brief example below

       

      Total JobsMileageMileage By Customer

      91261134
      17878
      181673006
      53211113
      15112619026
      16781248
      11016718370
      199171
      663378
      3033990
      4413572
      27952565
      2164328
      2833924
      5013650
      34953230
      5107535
      6031388836964

       

      The rows are fine it is the totals thats causing the issue ?

       

      Any help greatly appreciated

       

      Thanks

       

      Aaron

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Aaron197899 ,

     

    A*C +B*D <> (A+B) * (C+D)

     

    See the differences:

    Measure = SUMX('Mileage & CO2',[Mileage]*[Total Jobs])
    Measure 2 = SUM('Mileage & CO2'[Mileage]) * SUM('Mileage & CO2'[Total Jobs])

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.