Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Cross join tables

Hi! 

I need help cross joining two tables. 

 

I have one table that looks like this: 

Table "Openings hours"

 

StoreWeekdayHours open
Store 1Mo8
Store 1Tu7
Store 1We5
Store 1Th10
Store 2Mo4
Store 2Tu3
Store 2We2
Store 2Th1

 

Then I have a Dim Date table:

 

DateWeekday
feb 1 2021Mo
feb 2 2021Tu
feb 3 2021We
feb 4 2021Th

and so on... 

 

I would like to create a new table that gives me the opening hours per date and store: 

 

StoreDateHours open
Store 1feb 1 20218
Store 1feb 2 20217
Store 1feb 3 20215
Store 1feb 4 202110
Store 2feb 1 20214
Store 2feb 2 20213
Store 2feb 3 20212
Store 2feb 4 20211

and so on....

 

I need help with a smart solution! 

 

Cheers! 

Maria

 

  • In the Query Editor, you can merge Opening Hours table onto the Dim Date table joining on Weekday and then expand the Store and Hours open columns.

3 Replies

  • In the Query Editor, you can merge Opening Hours table onto the Dim Date table joining on Weekday and then expand the Store and Hours open columns.

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    Anonymous 

     

    If you want to do this in a visual in the report, you can use:

    1) 

    Sum of hours = SUM('Opening Hours'[Hours open])

    2) 

    Hours by date =
    CALCULATE (
        [Sum of hours],
        TREATAS ( VALUES ( 'Date Table'[Weekday] ), 'Opening Hours'[Weekday] )
    )

      and create the visual using the Date field from the Date Table and the Store from the Opening Hours Table:

     

  • Anonymous , 

    Step 1: Join the two tables based on the Weekdays. 

    Step 2: Then drag the Stores, date, and hours open from the respective tables on Table visual.