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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
seba
Helper II
Helper II

Help with visual

Hi all,

I’m working on a Power BI report and need help shaping the data to visualize device distribution across span value ranges over time.

For each report run date, I have multiple entries per device, each with a different span value. What I want to do is:

  • Only consider the maximum span value per device per report date

  • Group those max span values into defined buckets (e.g., 20–30, 30–40, 40–50, etc.)

  • Count how many devices fall into each bucket for each report date

  • Visualize how these counts change over time using a graph (bar, line, etc.)

Example of expected outcome (bolded in the example are values I would like to count):

  • Date A:

    • 2 devices in the 30–40 bucket

    • 1 device in the 20–30 bucket

  • Date B:

    • 1 device in the 40–50 bucket

    • 1 device in the 30–40 bucket

    • 1 device in the 20–30 bucket

I’ve tried grouping and using MAX functions, followed by counting, but I haven’t been able to get the data in the shape I need for the visual.

Any suggestions on how to approach this transformation in Power BI (Power Query or DAX) would be greatly appreciated!

Thanks in advance.

 

 

 

Report Date

Device nameSpan
Date ADevice A31
Date ADevice A30
Date ADevice A29
Date ADevice A28
Date ADevice A27
Date ADevice B33
Date ADevice B32
Date ADevice B31
Date ADevice B30
Date ADevice C20
Date ADevice C19
Date ADevice C18
Date BDevice A32
Date BDevice A31
Date BDevice A30
Date BDevice A29
Date BDevice A28
Date BDevice B42
Date BDevice B41
Date BDevice B40
Date BDevice B39
Date BDevice B38
Date BDevice B37
Date BDevice C22
Date BDevice C21
Date BDevice C20
Date BDevice C19
Date BDevice C18
Date BDevice C17
Date BDevice C16
3 REPLIES 3
v-sshirivolu
Community Support
Community Support

Hi @seba  ,
Thanks for reaching out to the Microsoft fabric community forum.

Create Span Bucket Column
Span Bucket =
SWITCH(
TRUE(),
'GroupedTable'[MaxSpan] >= 20 && 'GroupedTable'[MaxSpan] < 30, "20-30",
'GroupedTable'[MaxSpan] >= 30 && 'GroupedTable'[MaxSpan] < 40, "30-40",
'GroupedTable'[MaxSpan] >= 40 && 'GroupedTable'[MaxSpan] < 50, "40-50",
"Other"
)

Create a Summary Table
Span Distribution =
SUMMARIZE(
'GroupedTable',
'GroupedTable'[Report Date],
'GroupedTable'[Span Bucket],
"DeviceCount", COUNTROWS('GroupedTable')
)

Please find the attached .pbix file for your reference

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Best Regards,
Sreeteja.
Community Support Team

mdaatifraza5556
Solution Specialist
Solution Specialist

Hi @seba 

Create calculated table using below dax.

MaxSpanPerDevice =
SUMMARIZE(
    'Table',
    'Table'[Report Date],
    'Table'[Device name],
    "MaxSpan", MAX('Table'[Span])
)
 
Screenshot 2025-06-23 173535.png

 

Now create calculated col using below dax.

SpanBucket =
SWITCH(
    TRUE(),
    [MaxSpan] >= 20 && [MaxSpan] < 30, "20–30",
    [MaxSpan] >= 30 && [MaxSpan] < 40, "30–40",
    [MaxSpan] >= 40 && [MaxSpan] < 50, "40–50",
    "Other"
)
 
Screenshot 2025-06-23 173652.png

 

Result in tabular and in clustored column chart.

Screenshot 2025-06-23 174314.png

 

If this answer your questions, kindly accept it as solution and give kudos.
DataNinja777
Super User
Super User

Hi @seba ,

 

You can effectively shape your data to visualize device distribution over time using two primary methods in Power BI: Power Query for pre-processing the data, or DAX for creating dynamic calculations. The Power Query approach is often recommended for this type of transformation as it cleans and structures the data at the source, which can lead to better report performance.

 

To begin with Power Query, you would first open the Power Query Editor from the "Transform data" option on the Home tab. The initial step is to isolate the maximum span value for each device on each report date. This is achieved by using the "Group By" feature. You would configure it to group by both the Report Date and Device name columns. Then, you would create a new column, named for instance Max Span, by applying the Max operation to your Span column. This action condenses your data, leaving only the single highest span value for every unique device on a given date.

 

Following the initial grouping, the next step is to categorize these maximum span values into defined buckets. This is done by adding a "Conditional Column" from the "Add Column" tab. You can name this column Span Bucket and create a series of rules to assign each Max Span value to a bucket. For example, you would set a rule where if Max Span is greater than or equal to 40, the value is "40-50", and another rule where if it's greater than or equal to 30, the value is "30-40", and so on. It is important to order these rules from highest to lowest to ensure correct categorization.

 

Once the buckets are defined, the final transformation step in Power Query is to count how many devices fall into each bucket for each report date. You would use the "Group By" feature again, this time grouping by Report Date and the newly created Span Bucket column. You would add a new column, perhaps called Device Count, using the Count Rows operation. After completing these steps, you can click "Close & Apply" to load the perfectly shaped table—containing Report Date, Span Bucket, and Device Count—into your Power BI model, ready for visualization.

 

Alternatively, if you prefer a more dynamic approach within the Power BI report view, you can use Data Analysis Expressions (DAX). First, you would create a new calculated table. Navigate to the Data view, select "New table," and use a DAX expression to produce a summarized table that contains the maximum span value for each device and date.

MaxSpanPerDevicePerDate =
SUMMARIZE(
    YourTableName,
    YourTableName[Report Date],
    YourTableName[Device name],
    "Max Span", MAX(YourTableName[Span])
)

After creating this table, you would add a calculated column to it for the span buckets. Select the new table and click "New column," then input a DAX formula using the SWITCH function to assign each Max Span value to its respective bucket.

Span Bucket =
SWITCH(
    TRUE(),
    [Max Span] >= 40, "40-50",
    [Max Span] >= 30, "30-40",
    [Max Span] >= 20, "20-30",
    "Other"
)

With the data prepared using DAX, you can build your visual. You will need a measure to count the devices. You can create one by right-clicking on your new table and selecting "New measure."

Device Count = COUNTROWS('MaxSpanPerDevicePerDate')

For the visualization itself, a stacked column chart or a line chart would be highly effective. For a stacked column chart, you would place Report Date on the X-axis, the Device Count measure on the Y-axis, and the Span Bucket column in the Legend field to see the distribution within each bar. For a line chart, the configuration would be the same, which would allow you to clearly see the trend of each device bucket over time.

 

Best regards,

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.