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

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
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.