Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
shankyy7227
Frequent Visitor

Count of X below 48hrs

Hello All,

 

I have a table as shown below and i am trying to calculate count of FName below 48 hrs.

 

FNAMELNAMEMNAMEEntry DateEntry TimeExit DateExit Time
ABCDX6/6/201820:00:00 PM6/9/201821:00:00 PM
BCEFY6/6/201819:00:00 PM6/10/201819:00:00 PM
ABCDX5/30/201820:00:00 PM5/31/201822:00:00 PM
IHPQZ5/30/201824:00:00 PM6/1/201817:00:00 PM
IMPYC5/30/201818:00:00 PM6/2/201800:00.0
   5/30/201818:00:00 PM6/3/201818:00:00 PM
MEEEB5/30/201818:00:00 PM6/4/201818:00:00 PM
ABCDX5/30/201818:00:00 PM6/5/201818:00:00 PM
BCEFY6/6/201818:00:00 PM6/9/201818:00:00 PM

 

 

Please help me.

 

Thanks

1 ACCEPTED 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


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Hardik
Continued Contributor
Continued Contributor

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

Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @shankyy7227

 

Aren't all the rows under 48 hours?  I'm guessing you mean the values in the [Time] column?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I am trying calculate total number of people staying past 48 hours.

 

We need to combine Date and Time column here

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.