Forum Discussion
summing time utilization
I have the following formula that is calculating the number of days an asset is available during a given month:
This is quick and dirty.
Measure =
IF(
ISINSCOPE(RentalTable[Stock#]),
[DaysAvail],
SUMX(
ALLSELECTED('RentalTable'[Stock#]),
[DaysAvail]
)
)
I'd recommend creating star schema for better scalable DAX.
9 Replies
- kushanNaSuper User
can you try this measure ?
RentalContract_TotalCount = SUMX( VALUES(RentalTable[Stock#]), VAR fleetstart = MINX(FILTER(RentalTable, RentalTable[Stock#] = EARLIER(RentalTable[Stock#])), RentalTable[DateOut]) VAR fleetend = TODAY() RETURN CALCULATE( COUNT(RentalContractCalendar[Date]), RentalContractCalendar[Date] >= fleetstart && RentalContractCalendar[Date] <= fleetend ) )- ChiefHelper II
It appears this measure sums inaccurately. When I run it, I see 619 days for calendar year 2024 when I should see 366. The fleet start date on this unit was 7/10/23, thus when I pull in year 2023 it counts 175 days for 2023 and 619 for 2024.
- Tutu_in_YYCSuper User
Try:
SUMX(
ALLSELECTED('Table'[Stock#]),
[Days Avail]
)- ChiefHelper II
Tutu - this link is my rental table. I tried your suggestion but the calculation totals all lines, not just the total. Maybe seeing the visual will help understand my desired outcome. When one of the assets is filtered, everything works fine. When the filter is removed, the DaysonRent calcuate a total like they should, the daysavail don't total. Any help is appreciated:
https://drive.google.com/file/d/1e3TdNDOW7pmDy6t90QfAzqRP3SX12hIA/view?usp=sharing
- Tutu_in_YYCSuper User
- kushanNaSuper User
Hi
Try this measure ?
DaysAvail1 = VAR fleetstart = COALESCE(MIN(RentalTable[FleetDate]), MIN(RentalTable[DateOut]), TODAY()) RETURN SUMX( VALUES(RentalTable[Stock#]), COUNTROWS(INTERSECT(VALUES(RentalContractCalendar[Date]), CALENDAR(fleetstart, TODAY()))) )