I am trying to write a measure that will allow me to count how many customers purchased items at what time of the day. For example how many customers bought something between 9:00 AM and 10:00 AM.
I have a column in my table that has just times purchased:
I am also trying to understand trends on different days. So I have a date calendar I have linked to the table as well.
I thought about using the switch function but I am not having much luck with it.
Do you have a Time Dimension table in your Model?
If not hereâs a topic on that. BTW you will probably want to cut the Time down to the Minute or Hour level if that is the granularity of reporting. Because that will have a huge impact on the cardinality of the column, model size and performance.
Thanks for sending this. I added a time table in addition to the date table I have. I tried to do a lookup value from the time a customer purchased to the period of the day to do counts but it gave me blanks.
I also still canât seem to link specific hours either.
Yeah the granularity of the Time table is at the Minute level and your fact data at the Second so these donât match⌠Like I suggested earlier you will probably want to cut the Time down to the Minute or Hour level if that is the granularity of reporting.That will have a huge impact on the cardinality and thus model size and performance.
I appreciate all your help. Iâm not sure how this query helps me. I want to convert the column in an existing table to remove the seconds from the time.
When I run this query it only gives me a single date and time:
You have shown a âTime_Createdâ column that is of type time I would expectâŚ
Go to that Query and on the âAdd Columnâ tab select âCustom Columnâ a dialog box will be shown:
There you can enter this M code: Time.From ( Time.ToText( [Time_Created], âHH:mmâ) )
Finally in the formula bar (before the closing parenthesis) you can declare type, as shown here: