Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Need Help calculating sum for a given date

Hello

 

I am trying to calculate the sum of Minutes for a certain Tool on a given date. For example on 12/2 ToolA ran for a total of 20 minutes and on 12/3 it ran for 6 minutes. 

Date - Tool Name - Minutes 

12/2/2020Tool A 10
12/2/2020Tool B 5
12/2/2020Tool A 10
12/3/2020Tool C4
12/3/2020Tool A 6

 

I used the SUMX function using EARLIER with the Tool column but had no luck.

Thank you. 

  • Anonymous , In power bi Visual Sum option for a column should give you .

     

    or you can create a measure

    Measure = Sum(Table[Minutes])

     

    Unless you need Sum on A(Tool Name) together in a new column 

    New column= sumx(Filter(Table,[Tool Name] =earlier([Tool Name])),Table[Minute)

  • Hi Anonymous ,

     

    Yes, you can use the following measure:

     

    measure = IF(CALCULATE(SUM('Table'[Minutes]),FILTER('Table','Table'[Date]<=MAX('Table'[Date])&&'Table'[Date]>=MAX('Table'[Date])-2))>=20,"High","Low")

     

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

     

    Best Regards,

    Dedmon Dai

6 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    Anonymous  What format do you want the final result in? You can get this with the matrix visual if you put: 

    Tool, Date in Rows

    Minutes in Values (with SUM as summarization, that should be default)

     

    Then expand each tool to see each date. 

     

    You can swap the order too, put Date, Tool in rows to see each date by Tool. 

     

     

     

  • Hi,

    Create a Calendar Table and a build a relationship between the Date column of your Data Table to the Date column of your Calendar Table.  Create a slicer from the Date column of the Calendar Table and select any one date.  To your visual, drag Tool Name from the Data Table and write this measure

    Meaure = sum(Data[Minutes])

    Hope this helps.

  • Anonymous , In power bi Visual Sum option for a column should give you .

     

    or you can create a measure

    Measure = Sum(Table[Minutes])

     

    Unless you need Sum on A(Tool Name) together in a new column 

    New column= sumx(Filter(Table,[Tool Name] =earlier([Tool Name])),Table[Minute)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! The new column measure worked for me. I would like to flag as "High" if the total minutes in a 2 day period exceeds 20 minutes, any recommendation on how to do this?  I know it is needed to use a an if statement, but for showing a 2 day periosd would it be "Date"-2? 

       

      Thank you. 

      • v-deddai1-msft's avatar
        v-deddai1-msft
        Community Support

        Hi Anonymous ,

         

        Yes, you can use the following measure:

         

        measure = IF(CALCULATE(SUM('Table'[Minutes]),FILTER('Table','Table'[Date]<=MAX('Table'[Date])&&'Table'[Date]>=MAX('Table'[Date])-2))>=20,"High","Low")

         

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

         

        Best Regards,

        Dedmon Dai