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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Daisyhill
New Member

Average percentage by month and year

Hi,

 

I have been looking and trying differnt solution on this forum, but still get my head around to do this.  I hope someone will be able to help.

 

Daisyhill_1-1666109405173.png

 

This is the data I'm working on.  I want to calculte the average occupany rate per month for each building.

 

I managed to create 2 calcualted columns for Month and Year Number. 

I also I created a measure to calculate the daily occupancy rate --> Occupancy Rate = DIVIDE([Daily Count],AVERAGE('Tbl_Security_Data'[Building Capacity])

 

But now I'm stuck at the last step to get the monthly average, for example, in July should be 20% .

 

Daisyhill_2-1666109697058.png

 

I never have any sort of training on DAX, I only know some of the functions can't be used in combination of meausres / calculated columns?!?  This is why I'm so confused I can't use all the existing data to create what I want.

 

Thanks in advance for any help.

 

 

6 REPLIES 6
amitchandak
Super User
Super User

@Daisyhill , Create a measure like

 

Occupancy Rate = DIVIDE(Sum('Tbl_Security_Data'[Daily Count]),Sumx(Summarize('Tbl_Security_Data', 'Tbl_Security_Data'[Date],[Building Capacity])))

 

Assuming Daily Count is a column

Thanks @amitchandak 

 

I can't create a measure with daily count, this column is a measure - 

Daily Count = CALCULATE(DISTINCTCOUNT('Tbl_Security_Data'[Token number])).  Am I making too complicated for myself?
 
I can rearrange the data showing the token number instead, it will show the exact number (i.e. 22 counts on 8 July) like this, is it possible to create a measure with these instead?
 
Daisyhill_0-1666116091256.png

Thanks.

 

@Daisyhill , Use that like

 

Occupancy Rate = DIVIDE([Daily Count],Sumx(Summarize('Tbl_Security_Data', 'Tbl_Security_Data'[Date],[Building Capacity])))

@amitchandak  Thanks, really appreciate for your help.

 

I tried but it comes up with an error:

 

Daisyhill_0-1666117332431.png

Daisyhill_1-1666117471669.png

 

Is it to do with the format of the columns?

Also, is the measure you created to return the daily occupancy rate or monthly average?

 

@Daisyhill , Sorry My mistake, Try like

 

Occupancy Rate = DIVIDE([Daily Count],Sumx(Summarize('Tbl_Security_Data', 'Tbl_Security_Data'[Date],[Building Capacity]), [Building Capacity]))

@amitchandak Thanks and it works!

 

But this only showing the daily occupancy rate, is it possible to calculate a monthly average like this:

 

Daisyhill_0-1666119203335.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.