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

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.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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