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
petermb72
Helper III
Helper III

Using a constant in a measure

Here is some of the data that I am working with.  It is a very simple question but I am just not able to wrap my head around how to fix it.

 

LocationMax OCC
Fargo8
Moorhed4
West Fargo12

 

LocationMax OccRoom #Date
Fargo8112/1/2019
Fargo8312/1/2019
Fargo8412/1/2019
Fargo8712/1/2019
Fargo8812/1/2019
Fargo8112/2/2019
Fargo8312/2/2019
Fargo8212/2/2019
Fargo8412/2/2019

 

The tables are lined by location.  I have two additional measures that tells me how many days in the month, as well as a measure that will sum up the total number of rooms rented in the month.  The issue comes in with the Max Occupancy.  I want my formula to work like this:

Average Monthly OCC = divide([sumofroomsrented],([#daysinaMonth]*Max Occupancy

 

Its the Max Occupancy that I have an issue with.  How do I get the Measure just to use the one Max Occupancy of 8?  I have other locations with other max occupancies so as I use my slicer it needs to pick the correct max occupancy.  Should be easy but the answer is not coming to me.

9 REPLIES 9
v-alq-msft
Community Support
Community Support

Hi, @petermb72 

 


If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. Thanks.

 

 

Best Regards,

Allan

 

Ashish_Mathur
Super User
Super User

Hi,

In a Table format, show thr exact result that you are expecting.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

LocationMax OCC
Fargo8
Moorhead14
West Fargo21

 

locationRoom #Date
Fargo112/1/2019
Fargo312/1/2019
Fargo412/1/2019
Fargo512/1/2019
Fargo612/1/2019
Fargo712/1/2019
Fargo812/1/2019
West Fargo212/1/2019
West Fargo312/1/2019
West Fargo412/1/2019
Moorhead212/1/2019
Moorhead312/1/2019
Moorhead412/1/2019
Moorhead512/1/2019
Moorhead612/1/2019
Moorhead712/1/2019
Fargo112/2/2019
Fargo212/2/2019
Fargo312/2/2019
Fargo412/2/2019
West Fargo112/2/2019
West Fargo212/2/2019
West Fargo312/2/2019
West Fargo412/2/2019
Moorhead112/2/2019
Moorhead212/2/2019
Moorhead312/2/2019
Moorhead412/2/2019
Moorhead512/2/2019

 

I want to show Total number of rented rooms/max number of rooms per location.  I want to be able to use a slicer to choose what location.  The issue I have is that when I say I want Max Occ.  I get the max occupancy of the location table for all locations.  Not just the selected location in the slicer.  So for example if I wanted to get the percentage occupancy for the 12/1/2019 for Moorhead,  I would set slicer to the correct date, set slicer to Moorhead(Location Table),  I would then have a measure that would be Sum of Room #/Max OCC.  So I want 6/14 to give me a pertencage of 42.8%.  What I am getting is 6/21.  The 21 being the max occupancy of the location table. 

I hope this brings a little more clarity as to what I am looking for.

 

Thanks,

Peter

I also have a date table that says Dec has 31 Days, January has 31 days ect.....

 

So the calulation would be:  Count Rooms rented/ (number of days in month*maxocc)

or for the YTD  Count of rooms rented for year/(number of days in ytd*maxocc)

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
TomMartens
Super User
Super User

Hey, 

 

from my understanding you are pulling the column MAX OCC from the table of the one side of the relationship to the manyside.

If this assumption is correct give this a try:

Average Monthly OCC = 
	AVERAGEX(
		'<table on the many side>'
		, divide([sumofroomsrented],([#daysinaMonth]*RELATED('tableontheoneside>'[Max Occupancy])))
	)

Hopefully this provides what you are looking for.

 

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
v-alq-msft
Community Support
Community Support

Hi, @petermb72 

For the example of two tables you have created, you can create the measures as follows.

 

daysinaMonths = Day(Date(Year(max('Table B'[Date])),month(max('Table B'[Date]))+1,1)-1)

 

sumofroomsrented = CALCULATE(SUM('Table B'[Room]),FILTER(ALLSELECTED('Table B'),'Table B'[Location] in FILTERS('Table A'[Location])))

 

Max Occupancy = MAX('Table B'[Max Occ])

 

Average Monthly OCC = DIVIDE([sumofroomsrented],[daysinaMonths]*[Max Occupancy])

 

 

Result:

case2.png

If I misunderstand the your thoughts, please inform me of your expected output. I am glad to solve the problem for you.

 

Best Regards,

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Allen, 

Thanks for responding.  THe issue I am having is sitll with the max occupancy.  I have several locations all with different max occupancies.  if I use MAX (MaxOCC), I am not going to get the max for the right property chosen when I use a slicer to choose the single property.  I will always get the max.  Does that make sence?

Allen I think we are just about there.  Do I need to try to explain the issue any more?  I think I just need a last little step to figure this out.

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.