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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

@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
Super User
Super User

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?

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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