Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello All,
I have data that shows the when a rep enters a mall (In) and leaves a mall (Out) I would like to be able to calculate how long the rep spends within a mall in minutes.
The data looks like this
Rep | Location | Status | Date Time |
Rep 1 | Massey Mall | In | 2016/11/1 8:20 |
Rep 2 | Crown Mall | In | 2016/11/1 8:30 |
Rep 3 | Pacific Mall | In | 2016/11/1 8:40 |
Rep 2 | Crown Mall | Out | 2016/11/1 10:20 |
Rep 1 | Massey Mall | Out | 2016/11/1 11:00 |
Rep 3 | Pacific Mall | Out | 2016/11/1 12:00 |
Rep 2 | Crown Mall | In | 2016/11/2 8:00 |
Rep 1 | Massey Mall | In | 2016/11/2 8:20 |
Rep 3 | Pacific Mall | In | 2016/11/2 9:30 |
Rep 1 | Massey Mall | Out | 2016/11/2 10:00 |
Rep 3 | Pacific Mall | Out | 2016/11/2 10:00 |
Rep 2 | Crown Mall | Out | 2016/11/2 12:00 |
The output I am after is something like this on the out status
Rep | Location | Status | Date Time | Time Spent In Mall (Minutes) |
Rep 1 | Massey Mall | In | 2016/11/1 8:20 | |
Rep 2 | Crown Mall | In | 2016/11/1 8:30 | |
Rep 3 | Pacific Mall | In | 2016/11/1 8:40 | |
Rep 2 | Crown Mall | Out | 2016/11/1 10:20 | 110 |
Rep 1 | Massey Mall | Out | 2016/11/1 11:00 | 160 |
Rep 3 | Pacific Mall | Out | 2016/11/1 12:00 | 200 |
Rep 2 | Crown Mall | In | 2016/11/2 8:00 | |
Rep 1 | Massey Mall | In | 2016/11/2 8:20 | |
Rep 3 | Pacific Mall | In | 2016/11/2 9:30 | |
Rep 1 | Massey Mall | Out | 2016/11/2 10:00 | 100 |
Rep 3 | Pacific Mall | Out | 2016/11/2 10:00 | 30 |
Rep 2 | Crown Mall | Out | 2016/11/2 12:00 | 240 |
I am not sure if a calculated column is the best solution and have no idea where to start. Any help would be appreciated.
Thank you,
Adam
Solved! Go to Solution.
Hi, please follow this and try with your data:
1: Create two columns Date and Hour
Date = Table1[Date Time].[Date]
Hour = TIME(HOUR(Table1[Date Time]);MINUTE(Table1[Date Time]);SECOND(Table1[Date Time]))
2. Create a measure to calculate the time spent in the mall
TimeSpent = IF ( AND ( HASONEVALUE ( Table1[Status] ), VALUES ( Table1[Status] ) = "OUT" ), CALCULATE ( MAX ( Table1[Hora] ), ALLEXCEPT ( Table1, Table1[Rep], Table1[Location], Table1[Date] ) ) - CALCULATE ( MIN ( Table1[Hora] ), ALLEXCEPT ( Table1, Table1[Rep], Table1[Location], Table1[Date] ) ) )
2. Create a measure to convert in minutes
TimeInMinutes = HOUR([TimeSpent])*60+MINUTE([TimeSpent])
Hi @Adamzzzz
I've had a look at what you have done and tweaked it a bit. It should be working now 🙂
This is the result:
This is what I've done in the query:
I have made a new measure:
Time spent 2 =
CALCULATE(max(Table2[Minutes]);ALLEXCEPT(Table2;Table2[Rep];Table2[Location];Table2[Date - text]))
-CALCULATE(min(Table2[Minutes]);ALLEXCEPT(Table2;Table2[Rep];Table2[Location];Table2[Date - text]))
Note:
Hope it works for you,
Espen
Boa tarde...
Estou montando um BI com média de permanência na fábrica. Quero medir o tempo que veículos ficam para descarregar.
Já montei toda a estrutura mas estou com dificuldade na configuração do eixo Y. Não consigo configurar para mostrar hh:mm.
Teria alguma dica para resolver?
Hi @Adamzzzz
I was playing around with your data, but I didn't solve it, maybe this can lead you in the right direction though.
I did this in the query:
It might not be the smoothes way but I find numbers easier to work with than time.
Instead of measures, try playing around with "New collumns". I had luck with that earlier.
Good luck,
Espen
Hi, please follow this and try with your data:
1: Create two columns Date and Hour
Date = Table1[Date Time].[Date]
Hour = TIME(HOUR(Table1[Date Time]);MINUTE(Table1[Date Time]);SECOND(Table1[Date Time]))
2. Create a measure to calculate the time spent in the mall
TimeSpent = IF ( AND ( HASONEVALUE ( Table1[Status] ), VALUES ( Table1[Status] ) = "OUT" ), CALCULATE ( MAX ( Table1[Hora] ), ALLEXCEPT ( Table1, Table1[Rep], Table1[Location], Table1[Date] ) ) - CALCULATE ( MIN ( Table1[Hora] ), ALLEXCEPT ( Table1, Table1[Rep], Table1[Location], Table1[Date] ) ) )
2. Create a measure to convert in minutes
TimeInMinutes = HOUR([TimeSpent])*60+MINUTE([TimeSpent])
@Vvelarde Hello Victor, thank you for the response. I have tried the above measure and triple checking the correct spelling of the measure (making sure it is pointing to the correct columns). I recieve the following error-
Calculation error in meaure. A table of multiple values was supplied where a single value was expected.
As a calculated column I only recieve blank results. I am unsure what I am doing incorrectly? any help would be appreciated.
Any help would be appreciated. I cant figure this out
Hi @Adamzzzz
I've had a look at what you have done and tweaked it a bit. It should be working now 🙂
This is the result:
This is what I've done in the query:
I have made a new measure:
Time spent 2 =
CALCULATE(max(Table2[Minutes]);ALLEXCEPT(Table2;Table2[Rep];Table2[Location];Table2[Date - text]))
-CALCULATE(min(Table2[Minutes]);ALLEXCEPT(Table2;Table2[Rep];Table2[Location];Table2[Date - text]))
Note:
Hope it works for you,
Espen
Thank you Espen works great. Thank you everyone for your help!
Hi @Adamzzzz,
The measures provided by Vvelarde should work. Could you post the measure you're using? It's better to share a sample pbix file which can reproduce the issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.
Regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
75 | |
62 | |
51 | |
47 |
User | Count |
---|---|
213 | |
81 | |
64 | |
60 | |
56 |