Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello All,
I have a table as shown below and i am trying to calculate count of FName below 48 hrs.
FNAME | LNAME | MNAME | Entry Date | Entry Time | Exit Date | Exit Time |
AB | CD | X | 6/6/2018 | 20:00:00 PM | 6/9/2018 | 21:00:00 PM |
BC | EF | Y | 6/6/2018 | 19:00:00 PM | 6/10/2018 | 19:00:00 PM |
AB | CD | X | 5/30/2018 | 20:00:00 PM | 5/31/2018 | 22:00:00 PM |
IH | PQ | Z | 5/30/2018 | 24:00:00 PM | 6/1/2018 | 17:00:00 PM |
IM | PY | C | 5/30/2018 | 18:00:00 PM | 6/2/2018 | 00:00.0 |
5/30/2018 | 18:00:00 PM | 6/3/2018 | 18:00:00 PM | |||
ME | EE | B | 5/30/2018 | 18:00:00 PM | 6/4/2018 | 18:00:00 PM |
AB | CD | X | 5/30/2018 | 18:00:00 PM | 6/5/2018 | 18:00:00 PM |
BC | EF | Y | 6/6/2018 | 18:00:00 PM | 6/9/2018 | 18:00:00 PM |
Please help me.
Thanks
Solved! Go to Solution.
Hi @shankyy7227
I added the following calculated column to your table
Hours between Entry and Exit = VAR EntryDate = 'Table1'[Entry Time] VAR EntryTimeError = IF(EntryDate="24:00:00 PM",1,0) VAR CombinedEntryDateTime = 'Table1'[Entry Date] + TIMEVALUE(IF(EntryTimeError,"00:00:00",EntryDate)) + IF(EntryTimeError,1,0) VAR ExitDate = 'Table1'[Exit Date] VAR ExitCombinedDateTime = ExitDate + TIMEVALUE('Table1'[Exit Time]) RETURN DATEDIFF(CombinedEntryDateTime,ExitCombinedDateTime,HOUR)
Which then allowed me to create the following calculated measure to count the rows.
Measure = CALCULATE(COUNTROWS('Table1'),'Table1'[Hours between Entry and Exit]<= 48)
I have attached a PBIX file to this post
Column = IF(DATEDIFF(Table2[Entry Date],Table2[Exit Date],DAY)<2,1,0)
I hope this calculated column can be used a filter to meet your requirement
Hi @shankyy7227
Aren't all the rows under 48 hours? I'm guessing you mean the values in the [Time] column?
There may be in above sample data but they are not in real time data
So will the value in the [Time] column be something like '50:00.0' if it represented 50 hours - and this row should be excluded from the COUNT calculation?
Updated the above table, Please go through it once again.
Thanks 🙂
Hi @shankyy7227
I added the following calculated column to your table
Hours between Entry and Exit = VAR EntryDate = 'Table1'[Entry Time] VAR EntryTimeError = IF(EntryDate="24:00:00 PM",1,0) VAR CombinedEntryDateTime = 'Table1'[Entry Date] + TIMEVALUE(IF(EntryTimeError,"00:00:00",EntryDate)) + IF(EntryTimeError,1,0) VAR ExitDate = 'Table1'[Exit Date] VAR ExitCombinedDateTime = ExitDate + TIMEVALUE('Table1'[Exit Time]) RETURN DATEDIFF(CombinedEntryDateTime,ExitCombinedDateTime,HOUR)
Which then allowed me to create the following calculated measure to count the rows.
Measure = CALCULATE(COUNTROWS('Table1'),'Table1'[Hours between Entry and Exit]<= 48)
I have attached a PBIX file to this post
I am trying calculate total number of people staying past 48 hours.
We need to combine Date and Time column here
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
78 | |
59 | |
36 | |
33 |
User | Count |
---|---|
93 | |
59 | |
56 | |
49 | |
41 |