Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

PIVOT Table Alternative with SUMIF?

Hi experts!  

I'm trying to recreate Excel reports in Power BI and I am struggling with this one report as it has multiple aggregations.

In the screenshot attached, I've included a snippet of the source data, the table results expected and the additional pivot table that's created from the expected results.  Please note, I'm aware that PBI doesn't recoginze the special formattting of (h):mm:ss

Source data has potentially 2 rows for each Master Contact ID with different fields populated and Contact Skill Names.

I need to combine the rows by MasterID, so there is only a single row for each MasterID which includes both Prequeue and Inqueue times (which appear on different rows).  I've figured out how to do this in Power Query via Grouping.  So now, I have a new table with Unique MasterID's and their combined Prequeue/Inqueue details in a single row, but if I try to add the Contact End Date field to the aggregation in the grouping, I end up with the Dates being duplicated.  

I'm struggling with how to use the newly created table (with 1 row for each MasterID) to get a single row for a unique date so I can count the # of Master ID's from that date, plus the other 2 data columns sum/average etc.

I've tried various versions of the Measures that I've found on this forum:  CALCULATE(FILTER(SUM and even a SUMMARIZE formula 

Measure = SUMMARIZE('Source Data','Source Data'[Contact End Date Time],"Total Prequeue Time",SUM('Source Data'[Prequeue Time]))
(which is just giving me an error about expressions being scalar)
I've created a Date table, which contains unique dates but when I try to add the date from that table and the data from my Source Data table but every time I add in the Source Data I need, the dates just end up showing all rows for each date.
I have no doubt there is a super simple fix for this that I'm just not seeing.  I'm afraid I'm over complicating/thinking this, as I've been looking at it for a while now.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,

     

    Regarding the error you mentioned, the cause of the error is that the data type of a measure cannot be a table. Measures are typically single numerical values or calculation results, not tables containing multiple rows or columns of data. Since SUMMARIZE returns a table, I recommend creating a calculated table instead of a measure.

     

    CalculatedTable = 
    SUMMARIZE(
        'Source Data',
        'Source Data'[Contact End Date Time],
        "Total Prequeue Time", SUM('Source Data'[Prequeue Time])
    )

     

    Best Regards,

    Bof

3 Replies

  • I'm trying to recreate Excel reports in Power BI 

    Please stop doing that.  Power BI is not Excel. Use Power BI for its strengths. If you need that exact format then continue to use Excel.

    • Anonymous's avatar
      Anonymous
      Not applicable

      You are so right, time to rethink my strategy 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Regarding the error you mentioned, the cause of the error is that the data type of a measure cannot be a table. Measures are typically single numerical values or calculation results, not tables containing multiple rows or columns of data. Since SUMMARIZE returns a table, I recommend creating a calculated table instead of a measure.

     

    CalculatedTable = 
    SUMMARIZE(
        'Source Data',
        'Source Data'[Contact End Date Time],
        "Total Prequeue Time", SUM('Source Data'[Prequeue Time])
    )

     

    Best Regards,

    Bof