Forum Discussion

Tia Rojas's avatar
Tia Rojas
Copper Contributor
Apr 18, 2020

Adding number in the same table

I have the following table

If  fuel <> 0 then add a new column Total Miles = 0

IF fuel = 0 then the Total Mile = 0 + 10 = 10

If fuel = 0 then the Total Miles = 30 + 10= 40

If fuel <> 0 then Total Mile = 0

If fuel = 0 then Total mile = 0+5 = 5

If fuel <> 0 Then total mile = 0

If fuel = 0 then Total mile = 10

 

Creating the new table:

And the final table need to look like this

If Fuel <> 0 Then Sum Number will have the Miles + Total Mile = 20+0 = 0

If Fuel = 0 Then Sum Number = 0

If fuel = 0 Then Sum number = 0

If fuel <> 0 Then Sum number will have the Miles + Total Miles = 10 + 40 = 50

If fuel = 0 then Sum number = 0

If fuel <> 0 then Sum number will have the Miles + Total Miles = 6 + 5 = 11

If fuel = 0 then Sum number = 0

 

The final table will look like this

 

I am very new to Excel. Can someone give me an idea as to what to do.

 

I do know DAX but I don't have clue as to how I can apply DAX on exel

 

Thank you

8 Replies

  • mathetes's avatar
    mathetes
    Gold Contributor

    Tia Rojas 

    Would you permit me not to answer you directly? You mention knowing DAX but not Excel. I'd never heard of DAX, so went here https://docs.microsoft.com/en-us/dax/ and discovered it's a Microsoft software tool also and that it explicitly very closely resembles Excel in many of its functions.

     

    So let me challenge you first to realize that in Excel you can play around with those tentative entries and not need to worry about breaking anything. Perhaps the one thing you might need (as I said, I don't know DAX's way of writing a formula), is that in Excel you begin any formula or entry of a Function with the equals sign. So other than the cells where there's a number, you'd enter =10+20, not just 10+20. Or for your conditionals, it'd be =IF(.....) but what that DAX page tells me is that IF function in Excel is just the same as IF in DAX

     

    Be bold....try out the knowledge you already have. Then come back if you can't solve it on your own. My guess is that you can.

    • Tia Rojas's avatar
      Tia Rojas
      Copper Contributor

      mathetes

       

      As always I need this done yesterday. If you can give me some clue I would appropriate.

       

      Yes I know Power BI and DAX but exel is so different and new.

       

      Thanks

      • mtarler's avatar
        mtarler
        Silver Contributor

        Tia Rojas  ah Mathetes is ever the teacher.  I will be the bad student...

        assuming "miles" is in Col. C then I believe what you want is:

        Col E "Total Miles" would be

        =if(d2=0,c2+e1,0)

        and Col F "Sum of Miles" would be

        =if(d2=0,0,c2+e1)