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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Column Chart of Count Per Category

Hi!

 

I'm new to PowerBI and trying to make my first report related to data coming from EV charges. I'm stuck on how to make a column chart of a count of requested energy. This energyRequested remains constant for each charge but the data is per minute and not per charge.

 

This is my (simplified) dataset:

TimechargeIDenergyRequestedCurrent
09:5272016
09:5372016
09:5472015
09:5482511
09:5572015
09:5582511
09:5672015
09:5682511
09:5782510

 

As you can see, there are two charges happening (with ID 7 and 😎 and these require 20 and 25 kWh respectively.

 

I have made this barchart, which is close to what I'm looking for:

Capture.PNG

 

To make this, I used a quick measure 'Max per category' with 'Count of energyRequested' as base value and 'chargeID' as category. However, in the desired chart, each bar should only be 1 high as both 20 and 25 only appeared for 1 charge each. How can I do this? Thanks!

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@Anonymous 

The quickest way (perhaps not the most efficient one depending on the size of your tables) would be to create another table in which you keep only the most recent rows per ID:

NewTable =
FILTER (
    Table1,
    Table1[Time] = CALCULATE ( MAX ( Table1[Time] ), ALLEXCEPT ( Table1, Table1[chargeID] ) )
)

and then do the same as we did previously, but with the new table  instead:

 

1. Place NewTable[energyRequested] in the x-axis of your chart

2. Place this measure in the chart:

Measure = DISTINCTCOUNT( NewTable[chargeID] )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @Anonymous 

Try this:

1. Place Table1[energyRequested] in the x-axis of your chart

2. Place this measure in the chart:

Measure = DISTINCTCOUNT( Table1[chargeID] ) 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Anonymous
Not applicable

Works perfectly, thanks! A quick follow-up question;

 

Let's say a user changed their energyRequested during the charge, so the data might look like this (bold indicates changes😞

 

TimechargeIDenergyRequestedCurrent
09:5272016
09:5372016
09:5472015
09:5482511
09:5573015
09:5582511
09:5673015
09:5682511
09:5782510

 

How can I now make sure only the most recent (or highest) value is taken? i.e. how do I make sure the chart only has a column at 25 and 30, and not at 20?

AlB
Community Champion
Community Champion

@Anonymous 

The quickest way (perhaps not the most efficient one depending on the size of your tables) would be to create another table in which you keep only the most recent rows per ID:

NewTable =
FILTER (
    Table1,
    Table1[Time] = CALCULATE ( MAX ( Table1[Time] ), ALLEXCEPT ( Table1, Table1[chargeID] ) )
)

and then do the same as we did previously, but with the new table  instead:

 

1. Place NewTable[energyRequested] in the x-axis of your chart

2. Place this measure in the chart:

Measure = DISTINCTCOUNT( NewTable[chargeID] )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.