Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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")
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |