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
jcarter0713
New Member

Changing Formula based on Date Selection

Hello,

 

I am looking to create a utiization chart based on room utilization. The room will have a sum of the amount of hours used and I want to divide this by the total possible hours in a month to get the utilization %. This part is working fine. However, when I drill up to a year, the math is off because the dividing number is not large enough (Needs to be multiplied by 12). Is there a way to make this work with a single formula that changes based on the Date view of Month or Year?

1 REPLY 1
amitchandak
Super User
Super User

@jcarter0713 , You can get month of the date in context using

 

Month(Max(Date[Date]))

 

other ways

or

Utilization % =
VAR CurrentLevel = ISINSCOPE('Date'[Year]) + ISINSCOPE('Date'[Month])
VAR HoursUsed = SUM('RoomData'[HoursUsed])
VAR TotalHours =
SWITCH(
CurrentLevel,
2, EOMONTH(MAX('Date'[Date]), 0) - EOMONTH(MIN('Date'[Date]), -1) + 1, // Monthly level
1, 365 * (YEAR(MAX('Date'[Date])) - YEAR(MIN('Date'[Date])) + 1), // Annual level
BLANK()
)
RETURN
IF(
NOT ISBLANK(TotalHours),
HoursUsed / TotalHours,
BLANK()
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.