Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Timeslot range

Hi Team,

I have two datasets TIme(Slot, FromTime, ToTime) and Sales(Customer, Sales, InsertedDate, Date, Time). Now I want to display data for Resultset as (Customer,Sales, InsertedDate, Date, Time, Slot) in powerbi. I tried to do this using lookup which was failed and also tried to create a relationship among these two datasets which again failed. Please help.
Below is the link for datasets.
https://www.dropbox.com/scl/fi/1shxnek52yptlzevy1t7p/File.xlsx?dl=0&rlkey=slqt0wn3hp2blq9d19mife04n

Regards,
Srivalli

  • Hi Anonymous,

     

    Try this measure. No relationship exists between the two tables.

     

    Slot = 
    VAR vSalesTime =
        MAX ( Sales[Time] )
    VAR vTable =
        FILTER (
            'Time',
            vSalesTime >= 'Time'[FromTime]
                && vSalesTime <= 'Time'[ToTime]
        )
    VAR vResult =
        MAXX ( vTable, 'Time'[Slot] )
    RETURN
        vResult

     

     

8 Replies

  • Hi Anonymous,

     

    Try this measure. No relationship exists between the two tables.

     

    Slot = 
    VAR vSalesTime =
        MAX ( Sales[Time] )
    VAR vTable =
        FILTER (
            'Time',
            vSalesTime >= 'Time'[FromTime]
                && vSalesTime <= 'Time'[ToTime]
        )
    VAR vResult =
        MAXX ( vTable, 'Time'[Slot] )
    RETURN
        vResult

     

     

      • DataInsights's avatar
        DataInsights
        Super User

        Anonymous,

         

        In Power Query, change the datatype of FromTime and ToTime to "time" (not "datetime").

    • Anonymous's avatar
      Anonymous
      Not applicable

      DataInsights if we need to apply a slicer for slot field, will that be possible? because again we do not have relationship between the 2 datasets.

      Regards,
      Srivalli

      • DataInsights's avatar
        DataInsights
        Super User

        Anonymous,

         

        You may want to use a calculated column in the Sales table instead of a measure, due to the requirement to filter on the slot field.