The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have the following formula that is calculating the number of days an asset is available during a given month:
Solved! Go to Solution.
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.
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
)
)
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.
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())))
)
Thanks @kushanNa ! This is SO close. you can see that the DaysAvail column is summing the 5 entries at the 366 days for each column (total of 1830). I would like it to total 1,662 - the actual days available of the 5 entries. Any ideas?
Try:
SUMX(
ALLSELECTED('Table'[Stock#]),
[Days Avail]
)
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
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.
Gold Star Tutu!!! This works.