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
achybreaky
Frequent Visitor

Count of items with time and state conditions

Need help guys. I'm new in PowerBI. How can I count the items where the State is not yet set to Started (or still remains set to Approved) past 30 mins or more of its Start Date/Time. And also how can I count the items where the State is not yet set to Closed or still remains set to either Approved/Implement past 1 hour or more of its End Date/Time. Thanks in advance.

 

ItemStart Date/TimeEnd Date/TimeState
13/1/2024 06:00 PM3/1/2024 10:00 PMApproved
23/2/2024  1:00PM3/2/2024 5:00PMStarted
33/4/2024 3:30PM3/4/2024 11:30PMApproved
4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @achybreaky ,

Please create a new measure:

Count of items with over 30 mins and Started or Approved state = 
COUNTROWS (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Item],
            'Table'[Start Date/Time],
            'Table'[End Date/Time],
            'Table'[State],
            "@MINUTE", DATEDIFF ( 'Table'[Start Date/Time], 'Table'[End Date/Time], MINUTE )
        ),
        // filter out records with state 'Started' or 'Approved'.
        'Table'[State]
            IN { "Started", "Approved" }
        // and filter out records with endtime and starttime over 30 minutes or more. 
                && [@MINUTE] > 30
    )
)

vcgaomsft_0-1709695509628.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Thank you for your reply, I really appreciate it. I want to add more context to my problem. I was able to use this parameter in Servicenow but I want to use the same parameters to PowerBI. I also added additional item in the table for distinction. 

 

Basically I want to display two items in my PowerBI.  First is the number of items that had missed the Start Date/Time because the State still shows Approved instead of Started after 30 minutes or more past its Start Date/Time. Second the number of items that had missed the End Date/Time because the State still shows either Approved or Started after 1 hour or more past its End Date/Time. The count will remain as is until the correct State is updated. Items with future date/time are not supposed to be counted.

 

Missed Start Date/Time:
1. Start Date/Time is 30 Minutes ago from Now
2. Start Date/Time is less than today
3. State is Approved, not Started
3. Excluding future date


Missed End Date/Time:
1. End Date/Time is 1 hour ago from Now
2. End Date/Time is less than today
3. State is either Approved or Started, not Closed

 

 

 

ItemStart Date/TimeEnd Date/TimeState
13/1/2024 06:00 PM3/1/2024 10:00 PMApproved
23/2/2024  1:00PM3/2/2024 5:00PMStarted
33/4/2024 3:30PM3/4/2024 11:30PMApproved
43/8/2024 3:30AM3/8/2024 8:30AMApproved
lbendlin
Super User
Super User

Please provide a more detailed explanation of what you are aiming to achieve. What have you tried and where are you stuck?

Hi, 

 

Thank you for your reply.

 

I tried to use this formula and then use the filter pane to filter the state, but this doesnt provide the specific data if they missed updating the State 30 mins or 1 hour past the start or end date/time.

Missed Start =
CALCULATE (
    SUMX (
        Query3,
        IF (
            MAX ( [Start Date/Time] ) < TODAY () +1/24,
            1,
            0
        )
    )
)

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.

Top Solution Authors
Top Kudoed Authors