Forum Discussion
Three metrics in one
- 2 years ago
Hi Syndicate_Admin -create a measure that checks the status of vehicles across the three tables (Subscriptions, Bookings, and Vehicles) and counts how many vehicles have at least one active status (either active subscription, active booking, or are free/unpublished).
Create a measure checks if the subscription status is active
IsActiveSubscription =
IF (
SELECTEDVALUE(Subscriptions[Status]) = "Active",
1,
0
)This measure checks if the booking status is active
IsActiveBooking =
IF (
SELECTEDVALUE(Bookings[Status]) = "Active",
1,
0
)measure checks if the vehicle status is active or free/unpublished
IsFreeOrUnpublished =
IF (
SELECTEDVALUE(Vehicles[Status]) = "Active" || SELECTEDVALUE(Vehicles[Status]) = "Free/Unpublished",
1,
0
)create another measure counts vehicles where any of the three measures return 1.
CountActiveVehicles =
CALCULATE (
COUNTROWS ( Vehicles ),
FILTER (
Vehicles,
[IsFreeOrUnpublished] = 1 ||
CALCULATE ( [IsActiveSubscription], ALLEXCEPT(Subscriptions, Subscriptions[License Plate]) ) = 1 ||
CALCULATE ( [IsActiveBooking], ALLEXCEPT(Bookings, Bookings[License Plate]) ) = 1
)
)Hope it helps
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Hi Syndicate_Admin -create a measure that checks the status of vehicles across the three tables (Subscriptions, Bookings, and Vehicles) and counts how many vehicles have at least one active status (either active subscription, active booking, or are free/unpublished).
Create a measure checks if the subscription status is active
IsActiveSubscription =
IF (
SELECTEDVALUE(Subscriptions[Status]) = "Active",
1,
0
)
This measure checks if the booking status is active
IsActiveBooking =
IF (
SELECTEDVALUE(Bookings[Status]) = "Active",
1,
0
)
measure checks if the vehicle status is active or free/unpublished
IsFreeOrUnpublished =
IF (
SELECTEDVALUE(Vehicles[Status]) = "Active" || SELECTEDVALUE(Vehicles[Status]) = "Free/Unpublished",
1,
0
)
create another measure counts vehicles where any of the three measures return 1.
CountActiveVehicles =
CALCULATE (
COUNTROWS ( Vehicles ),
FILTER (
Vehicles,
[IsFreeOrUnpublished] = 1 ||
CALCULATE ( [IsActiveSubscription], ALLEXCEPT(Subscriptions, Subscriptions[License Plate]) ) = 1 ||
CALCULATE ( [IsActiveBooking], ALLEXCEPT(Bookings, Bookings[License Plate]) ) = 1
)
)
Hope it helps
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!