Forum Discussion

Samhunt's avatar
Samhunt
Helper II
2 years ago
Solved

Need Help with Sax

Hello guys, 

 

I want to count all different bookings that happened within a calendar year and have a specific status. 

 

I used the following formula which is of course wrong 🙂 Up to the part with the date I think I am right, I want to add the part that will only count bookings in the column "Status" it is either paid or confirmed.

 

Measure =
CALCULATE(
    DISTINCTCOUNT(
        Bookings[Booking number]),
        YEAR(Bookings[Check-out date] = 2023)
)
 
Wishing you a happy new year
  • Hi, Samhunt 

    try below

    Measure =
    CALCULATE(
        DISTINCTCOUNT(
            Bookings[Booking number]),
          filter(
            all(Bookings[Check-out date],Bookings[status]),
            YEAR(Bookings[Check-out date]) = 2023 &&
            Bookings[status] ="paid" || Bookings[status] ="confirmed"
          )
    )

2 Replies

  • Dangar332's avatar
    Dangar332
    Resident Rockstar

    Hi, Samhunt 

    try below

    Measure =
    CALCULATE(
        DISTINCTCOUNT(
            Bookings[Booking number]),
          filter(
            all(Bookings[Check-out date],Bookings[status]),
            YEAR(Bookings[Check-out date]) = 2023 &&
            Bookings[status] ="paid" || Bookings[status] ="confirmed"
          )
    )
  • Samhunt 

    One more version:

    Measure1 =
    CALCULATE (
        DISTINCTCOUNT ( Bookings[Booking number] ),
        YEAR ( Bookings[Check-out date] ) = 2023,
        Bookings[status] IN { "Paid", "Confirmed" }
    )