Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
adriancho_BI
Regular Visitor

How to summarize a table

Hello! PBI community, I´m trying to summarize a table. I'm trying to have the next output:
In the columns, the 24 hrs of the day

In the rows, te 7 days of the week, starting in monday
In the values, the distinct count of device_id

The structure are different transactions per date/time for every device_id, so I need to see the count for every hour and day, no matter the month or year.

 00:0001:0002:00

03:00

04:0005:0006:0007:00
Monday        
Tuesday        
Wednesday        
Thursday        
Friday        
Saturday        
Sunday        

 

Thanks in advance for the advice!

3 REPLIES 3
AnalyticsWizard
Super User
Super User

@adriancho_BI 

To achieve the desired output, you can create a matrix in Power BI that displays the distinct count of device_id for each hour of the day (24 hours) and each day of the week (starting from Monday). Here’s how you can set it up:

  1. Create a New Table:

    • In Power BI Desktop, go to the Model View.
    • Create a new table with the following columns:
      • Hour: Ranging from 00:00 to 23:00 (representing the 24 hours).
      • Day: Ranging from Monday to Sunday (starting from Monday).
  2. Create a Measure:

    • Go to Modeling ➡️ New Measure.
    • Enter the following DAX formula to calculate the distinct count of device_id:
      Distinct Device Count = DISTINCTCOUNT('YourTable'[device_id])
    • Replace 'YourTable' with the actual name of your data table.
  3. Create a Matrix Visualization:

    • Go back to the Data View.
    • Create a matrix visual.
    • Drag the Hour column to the Columns section of the matrix.
    • Drag the Day column to the Rows section of the matrix.
    • Drag the Distinct Device Count measure to the Values section of the matrix.
  4. Format the Matrix:

    • Format the matrix to display the days of the week in the desired order (starting from Monday).
    • Adjust the formatting of the matrix cells as needed (e.g., font size, alignment).
  5. Result:

    • Your matrix should now show the distinct count of device_id for each hour of the day and each day of the week.

Here’s how the matrix might look (simplified example):

Hour Monday Tuesday Wednesday … Sunday
00:001012158
01:00811149
23:00910137

Remember to adjust the table and column names according to your actual data.

Thank you so much for the detail in your steps. I followed these steps but I don't see the same result, maybe because the way I related those tables is not the correct way to do it. I do have a field in my 'YourTable' that is StartOfHour, where I expected to make it work but it doesn't. 😞

 

bsheffer
Continued Contributor
Continued Contributor

what happens if you pick 2 days?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.