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
pardeepd84
Helper III
Helper III

Calculated column not counting time properly

Hi,

 

I have created a calculated column which counts the ID, start date and start time which includes time from midnight to midnight. If is the same it will count the number of times it appears in the dataset, if any are blank it returns 0. However I have noticed that if the time is 00:00 it seems to be returning 0 rather than 1, 2, 3 etc even though the ID, start date and start time all have data in the cells.

 

Please could you advise how to resolve this. 

 

The formula I have written is:

Results3 =
VAR _currentrowID = 'Table (2)'[ID]
VAR _CRstartDate = 'Table (2)'[Start Date]
VAR _CRstartTime = 'Table (2)'[Start Time]
RETURN
    COUNTROWS (
        FILTER (
            'Table (2)',
            'Table (2)'[ID] = _currentrowID
                && _CRstartDate = 'Table (2)'[Start Date]
                && _CRstartTime = 'Table (2)'[Start Time]
                && 'Table (2)'[ID] <> BLANK ()
                && 'Table (2)'[Start Date] <> BLANK ()
                && 'Table (2)'[Start Time] <> BLANK ()
                && 'Table (2)'[ID] = _currentrowID
                && 'Table (2)'[Start Date] = _CRstartDate
                && 'Table (2)'[Start Time] = _CRstartTime
        )
    ) + 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@pardeepd84, Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

View solution in original post

3 REPLIES 3
pardeepd84
Helper III
Helper III

Please find attached sample data, I have exported the data into excel as there is a lot of sensitive/client identifiable information in my dataset in Power Bi.  

 

As mentioned above the formula is working for all other rows however if the time is recorded as 00:00 then it is not counting it, however it should be counting the number of times it appears in the dataset.  As the ID, start date and start time all have data entered in the cells it should either return 1 or if all three columns have the exact same data in it it should return a number dependent on how many times it appears in the dataset.  As you can see in the example below for ID 5432 has a start date and start time, as the data is the same and appears in the dataset twice it returns 2, however for ID 1234 it has a start date and start time so should return 1 or 2 if it appears in the dataset again. 

 

Midnight not counting.JPG

 

 

amitchandak
Super User
Super User

@pardeepd84, Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Please see sample data attached to this topic. 

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.