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
alya1
Helper V
Helper V

Please help display average count per month/year on stacked bar chart with date hierarchy

Hello, I have a data table as below:

DayItemInventoryEmptyFull
1/1/2023afull01
1/1/2023bempty10
1/1/2023cfull01
1/1/2023dfull01
1/2/2023afull01
1/2/2023bempty10
1/2/2023cfull01
1/2/2023dfull01
1/2/2023efull01
1/3/2023aempty10
1/3/2023bfull01
1/3/2023cfull01
1/3/2023dfull01
1/3/2023efull01

and so on but with many more items and days over 5 years.

I created a stacked bar chart with:
x-axis = Day with hiearchy

y-axis = Sum of Empty and Sum of Full 

It looks correct from the date level. When I Drill Up to Month it shows total sum. But I would like to see average.
For example Jan 2023 is currently showing Empty=3 and Full=11 but I would like for it to show Empty=1 and Full=3.666

I tired to simply select average in the visualization drop down but it shows me numbers less than 1 which is incorrect. 
Thank you!

1 ACCEPTED SOLUTION

@alya1 

create a new column

month = FORMAT('Table'[Day],"mmm")
 
then create two measures
Measure = sum('Table'[Empty])/DISTINCTCOUNT('Table'[Day])
Measure 2 = sum('Table'[Full])/DISTINCTCOUNT('Table'[Day])
11.PNG
pls see the attachment below
 
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@alya1 

how you get 3.666? what's the calculation logic?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It is from 11 (sum of all the 1s in Filled Column in Jan shown) divided by 3 (total days in Jan shown): 11/3=3.666666667

@alya1 

create a new column

month = FORMAT('Table'[Day],"mmm")
 
then create two measures
Measure = sum('Table'[Empty])/DISTINCTCOUNT('Table'[Day])
Measure 2 = sum('Table'[Full])/DISTINCTCOUNT('Table'[Day])
11.PNG
pls see the attachment below
 
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you @ryan_mayu ! May I ask how to expand this solution so it encompasses all 5 years of data please? There would be 5 Januarys

then you changed the column to 

yearmonth = year('Table'[Day]) & FORMAT('Table'[Day],"mmm")





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.