Forum Discussion

Spartanos's avatar
Spartanos
Icon for Helper II rankHelper II
3 years ago
Solved

Sumifs is not working

I have got a simple sumifs, but for some reason I am doing something wrong.  I try to calculate the sum of a tracking number if the 'type'= 'residential-adjustment. The countif function is working.  ...
  • Shaurya's avatar
    3 years ago

    Hi Spartanos,

     

    A much better way of getting the result that you want is to use SUMX along with EARLIER. This will add the charge column's numbers only when the tracking number is same and you can incorporate your condition for type column value to be "residential-adjustment" as well.

     

    Here's the formula:

     

    Sum_ifs_tracking_fuel = SUMX('Append',IF('Append'[Tracking number]=EARLIER('Append'[Tracking number]) && 'Append'[type]="residential-adjustment",'Append'[charge],0))

     

    I've tried it in your PBIX and it works.

     

     

    Mark this post as a solution if that works for you!

     

     

  • AilleryO's avatar
    3 years ago

    Hi,

     

    Two things to do for it to work.

    The good news is your formula is good, but it should be a measure and not a calculated column.

    So just keep your formula as it is but paste it in a Measure.

    Then create a visual with the tracking number (you use allselected tracking numbers, so it must be in your visual) and your measure and you'll get what you expect.

     

     

    Let us know 🙂