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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Count number of days and banks on a condition

I have this below table as a sample :

Bank_R   Bank_Date      endtime           delayGroup   IsDeadlinePassed 
47/6/20207/7/2020 11:58On time0
197/6/20207/7/2020 14:47On time0
197/6/20207/7/2020 9:12Delayed1
47/7/20207/8/2020 12:50On time0
197/7/20207/8/2020 15:16On time0
197/7/20207/8/2020 9:56Delayed1


I want to calculate number of days and number of banks which where 'On time' OR whose deadline was not passed which in this case is '0' .

 

In the table above what I should get as a result is :

 

No of banks on time = 1 (which is Bank_R = 4 in this case)
No of days on time = 2 (which is 7/6/2020 and 7/7/2020)


Besides this Bank_R and Bank_Date can be taken as user selection from slicers so I don't know if I can do something with Summarize. I am trying to play around with something like this below but it is of no use :

 

number of bank days.png

1 ACCEPTED SOLUTION
technolog
Super User
Super User

First, let's tackle the number of banks on time. You can use the CALCULATE function combined with DISTINCTCOUNT to count the unique banks that meet the criteria.

For the number of banks on time:

DAX
Copy code
NoOfBanksOnTime =
CALCULATE(
DISTINCTCOUNT('New Table'[Bank_R]),
'New Table'[delayGroup] = "On time" || 'New Table'[IsDeadlinePassed] = 0
)
Next, for the number of days on time, you'd again use CALCULATE but this time with DISTINCTCOUNT on the Bank_Date column.

For the number of days on time:

NoOfDaysOnTime =
CALCULATE(
DISTINCTCOUNT('New Table'[Bank_Date]),
'New Table'[delayGroup] = "On time" || 'New Table'[IsDeadlinePassed] = 0
)
Now, if you want to consider user selections from slicers, the ALLSELECTED function can be useful. However, in the context of your problem, if you're just using slicers on the Bank_R and Bank_Date columns, the above measures should automatically respect those slicer selections without needing to explicitly use ALLSELECTED.

 

View solution in original post

1 REPLY 1
technolog
Super User
Super User

First, let's tackle the number of banks on time. You can use the CALCULATE function combined with DISTINCTCOUNT to count the unique banks that meet the criteria.

For the number of banks on time:

DAX
Copy code
NoOfBanksOnTime =
CALCULATE(
DISTINCTCOUNT('New Table'[Bank_R]),
'New Table'[delayGroup] = "On time" || 'New Table'[IsDeadlinePassed] = 0
)
Next, for the number of days on time, you'd again use CALCULATE but this time with DISTINCTCOUNT on the Bank_Date column.

For the number of days on time:

NoOfDaysOnTime =
CALCULATE(
DISTINCTCOUNT('New Table'[Bank_Date]),
'New Table'[delayGroup] = "On time" || 'New Table'[IsDeadlinePassed] = 0
)
Now, if you want to consider user selections from slicers, the ALLSELECTED function can be useful. However, in the context of your problem, if you're just using slicers on the Bank_R and Bank_Date columns, the above measures should automatically respect those slicer selections without needing to explicitly use ALLSELECTED.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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