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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
lagacem
Frequent Visitor

Count Number of Rows Based on Filter From Current Row

Hello all,

 

Looking for help on this as I can get it to work in Excel but am having a hard time figuring it out in Power BI. What I'm trying to accomplish is to have at the end of each row, a count of how many INC were still open at the time on resolution. So basically where the opened_at_value of other rows < resolved_at_value this row AND resolved_at_value of other rows >resolved_at_value of this row

 

lagacem_0-1615988222605.png

 

In Excel I can simply get it done with COUNTIFS

 

image.png

 

I've tried using COUNTX, COUNTROWS with FILTER but it only returns the calculation on that specific row.

 
1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

Hi @lagacem,

You can try the next option:

#StillOpenedInc = 
VAR currentResolvedDate = SELECTEDVALUE('Table'[Resolved_date])
VAR Result = 
    COUNTROWS(FILTER(
            ALL('Table'),
            currentResolvedDate > 'Table'[Opened_date] &&
            currentResolvedDate < 'Table'[Resolved_date]
        ))
RETURN IF(ISBLANK(Result), 0, Result)

optiona.PNG

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos๏‘.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

4 REPLIES 4
AnkitKukreja
Super User
Super User

Hi @lagacem 

 

Hope this solves you're problem. Excel and Power BI are very similar, I've used if condition as a calculated column.

Still_Open =
IF ( Community_Sol[CLOSE_DATE] > Community_Sol[OPEN_DATE] , 0 , IF ( Community_Sol[CLOSE_DATE] = Community_Sol[OPEN_DATE] , 0 , 1 ) )

 

Community_Solution.PNG

You can also use "Earlier" function for the same.

 

Thanks,
Ankit
www.linkedin.com/in/ankit-kukreja1904

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Thank you for your help.

 

Unfortunately this isn't what I'm looking for. Yours seems to only show if its still open. What I'm looking for is a count of how many INC were opened but not closed when the INC on that row was closed.

 

In your table, for example, line 2 was closed the 11th. From that we have

Line 1 as it was closed on the 4th so counts as 0

Obviously we exclude line 2

Line 3 was opened the 9th (before the 11th) and not yet closed so that counts as 1

Line 4 was opened the 10th (before the 11th) and closed the 16th (after the 11th) and was thus still opened when line 2 was closed so it counts as 1

Line 5, 6 and 7 were alsc closed the 11th so they count as 0

Line 8 was opened the 12th so after the line 2 was closed so counts as 0

Line 9 was opened the 15th so after the line 2 was closed so counts as 0

 

What I would want is to have the value 2 in the new column at the end of line 2 which is the sum from end line listed above. And to repeat this process for each line.

 

I hope this has helped clarify my request

ERD
Community Champion
Community Champion

Hi @lagacem,

You can try the next option:

#StillOpenedInc = 
VAR currentResolvedDate = SELECTEDVALUE('Table'[Resolved_date])
VAR Result = 
    COUNTROWS(FILTER(
            ALL('Table'),
            currentResolvedDate > 'Table'[Opened_date] &&
            currentResolvedDate < 'Table'[Resolved_date]
        ))
RETURN IF(ISBLANK(Result), 0, Result)

optiona.PNG

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos๏‘.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

lagacem
Frequent Visitor

Works great thanks so much!

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)