Forum Discussion

Georgetimes's avatar
Georgetimes
Frequent Visitor
2 years ago
Solved

Inventory data help - calculate usage

Hi everyone,   Have the below sample data in two different tables.   BookingId Pickup Date DropOff Date Bicycle Type 1 27/02/2024 10/03/2024 A 2 27/02/2024 28/02/2024 A 3 28...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Georgetimes 

     

    For your question, here is the method I provided:

     

    Here's some dummy data

     

    "A"

     

    "B"

     

    Create a measure. Types are grouped, and the calculation rule is that Pickup Date is equal to Date_of_report or DropOff Date is greater than Date_of_report.

     

     

    Bookings = 
    VAR b_DATE = SELECTEDVALUE('B'[Date_of_report])
    RETURN 
        CALCULATE(
            COUNTROWS('A'), 
            FILTER(
                ALL('A'), 
                'A'[Bicycle Type] = MAX('A'[Bicycle Type]) 
                && 
                ('A'[Pickup Date] = b_DATE || 'A'[DropOff Date] = b_DATE)
            )
        )
    

     

     

    Create a measure to calculate usage.

     

     

    Usage = DIVIDE([Bookings], SELECTEDVALUE('B'[Number of bicycles in stock]))

     

     

    Here is the result.

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    bicycle.pbix35 KB