Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello!
I have a list stores with different opening/closing times, both store by store and by day of the week. I would like to generate a column that defines if a sale that has been recorded in a specific store was done within the hours the store was open to the public or when it should be closed.
I have started testing with a formula for Monday-Saturday, but I would like to extract the opening/closing time from a different table, depending on the store that has registered the sale.
Open-Closed Monday-Saturday = IF(Sales[Day_of_Week] <> "Sunday"; if (HOUR(Sales[Hour]) >= 9 && HOUR(Sales[Hour]) <= 21 ; "Open"; "Closed");"ERROR")
Do you have any idea how to (vastly) improve the formula?
Thanks a lot!
Solved! Go to Solution.
Hi @Rate,
How about:
Create 2 tables,
1. containing store data ('StoreData'), with columns:
- Store
- Opening (hour)
- Closing (hour)
- ClosedDay
2. for transactions ('Transactions'), with columns:
- Store
- TransactionDayOfWeek
- TransactionHour
The tables should have a relationship on the Store column.
Then, you can create the following column in the Transactions table:
open_or_closed = IF([TransactionDayOfWeek] <> RELATED(StoreData[ClosedDay]) && [TransactionHour] >= RELATED(StoreData[Opening]) && [TransactionHour] < RELATED(StoreData[Closing]), "Open", "Closed")
Hi @Rate,
How about:
Create 2 tables,
1. containing store data ('StoreData'), with columns:
- Store
- Opening (hour)
- Closing (hour)
- ClosedDay
2. for transactions ('Transactions'), with columns:
- Store
- TransactionDayOfWeek
- TransactionHour
The tables should have a relationship on the Store column.
Then, you can create the following column in the Transactions table:
open_or_closed = IF([TransactionDayOfWeek] <> RELATED(StoreData[ClosedDay]) && [TransactionHour] >= RELATED(StoreData[Opening]) && [TransactionHour] < RELATED(StoreData[Closing]), "Open", "Closed")
User | Count |
---|---|
139 | |
113 | |
103 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |