Forum Discussion

JDSang's avatar
JDSang
Frequent Visitor
6 years ago
Solved

SUMIFS in Power Bi

Hi, i'm pretty new to power Bi and am struggling to get my head around tasks that are simple in excel, i have a list of orders each with multiple time entries by different people over various months.

 

Normally in excel, i would use SUMIFS to sum the time column, if the order column matches order on the current row and the Month Column matches Month on the current row, which would give me the total for the order in that period. I would then divide the hours logged on that line by the total hours logged in the month to get the %age by that reviewer in the month. is this doable in power bi? i have two tables on summarises time by order, reviewer, year & month and a second table that summarises time by order, year then month.  but i'm struggling to merge them with multiple parameters

 

example of what i'm looking to create: 

 

OrderReviewerMonthHoursTotal Hours in MthPercentage logged
1JohnJan1520.00%
1NancyJan4580.00%
1GreggFeb5862.50%
1BillFeb1812.50%
1AnnFeb2825.00%
  • dax edhans 

     

    I seem to have answered my own question. I used:

    Month Hours = CALCULATE(SUM('Table'[Hours]),ALLEXCEPT('Table','Table'[Month]))
    The month hours matches the total for month on the second table.
     
    Thank you for your help 🙂

5 Replies

  • edhans's avatar
    edhans
    Community Champion

    Sure, but you don't need SUMIFS(). Power BI automatically filters for you based on the table filter connections and the visuals.

    See the attached file. It returns a percent of total to help out.

    The measure to get percent of total is:

     

    Percent of Total = 
    VAR CurrentHours = [Total Hours]
    VAR TotalHours = 
        SUMX(
            ALL('Table'),
            'Table'[Hours]
        )
    VAR Result = 
        DIVIDE(
            CurrentHours,
            TotalHours
        )
    RETURN
        Result

     

     

    The ALL('Table') tells DAX to ignore the filters on the row, so don't tell me Ann's total, tell me the total of everyone.

    If you need further help, please describe the issue in bit more detail, and what your source data looks like with samples.

     

    How to get good help fast. Help us help you.
    How to Get Your Question Answered Quickly
    How to provide sample data in the Power BI Forum

     

  • dax's avatar
    dax
    Community Support

    Hi JDSang , 

    You said that you want to merge two tables and get below result, so if possible could you please inform me more detailed information(such as your expected output and your sample data (by OneDrive for Business))? Then I will help you more correctly.

    Please do mask sensitive data before uploading.

    Thanks for your understanding and support.
    Best Regards,
    Zoe Zhi

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

     

    • JDSang's avatar
      JDSang
      Frequent Visitor

      Thanks  dax edhans .

       

      i have the below as my "core data" (Table1)

      Order

      Year

      Month

      Name

      Time

      3000

      2020

      1

      John

      0.1

      3000

      2020

      2

      Nancy

      6.5

      3000

      2020

      3

      Bill

      0.15

      3000

      2020

      3

      Dave

      0.6

      3000

      2020

      3

      John

      0.2

      3000

      2020

      3

      Dean

      4

      3000

      2020

      3

      Nancy

      16.5

      3000

      2020

      4

      Bill

      0.3

      3000

      2020

      4

      Dave

      0.65

      3000

      2020

      4

      John

      0.1

      3000

      2020

      4

      Dean

      0.85

      3000

      2020

      4

      Nancy

      2

       

      I also have the time logged by order (excluding Reviewer), this is Table 2

       

      Order

      Year

      Month

      Total for Month

      3000

      2020

      1

      0.1

      3000

      2020

      2

      6.5

      3000

      2020

      3

      21.45

      3000

      2020

      4

      3.9

       

      Nancy logged 2 hours in April out of 3.90 logged in total for April, how do I work out the percentage of her 2 hours for this particular order? note this a small sample, so the check on the reviewer, month and order needs to be change on every row, like a SUMIFS would in Excel:

       

      ReviewerOderDateHoursOrder Hrs/MthOrder Hours by Month
      John101-Jan15=SUMIFS(Hours,Reviewer,Current Row Reviwer,Month,current row month)
      Nancy104-Jan45=SUMIFS(Sum Range,Criteria Range, Criteria, Criteria Range 2, Criteria 2)
      John220-Jan22 
      John204-Feb49 
      Nancy206-Feb59 
      John107-Mar33 
      John315-Mar24 
      Nancy316-Mar24 

       

      hope this explains a bit better

      • JDSang's avatar
        JDSang
        Frequent Visitor

        dax edhans 

         

        I seem to have answered my own question. I used:

        Month Hours = CALCULATE(SUM('Table'[Hours]),ALLEXCEPT('Table','Table'[Month]))
        The month hours matches the total for month on the second table.
         
        Thank you for your help 🙂