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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Al_Padrini
Frequent Visitor

Count between two dates in slicer

Hi all,

 

I am trying to create a card visual that counts the number of current active destinations between launch and cease dates, as definied by a 'Between' date slicer, as below.

Al_Padrini_4-1710216278910.png

 

The data source I'm using is below. A blank cease date means that the destination is still serviced and it should be counted. 

City nameLaunch dateCease date
(if applicable)
Paris1/06/2021 
Dallas15/09/2021 
Amsterdam4/12/2021 
Tokyo Narita13/05/20225/01/2024
Bogota5/06/2022 
New York City17/08/202224/03/2023
Rome29/08/2022 
Lagos9/12/2022 
Shanghai30/12/202217/02/2024
Frankfurt20/01/2023 
Madrid7/07/2023 
Amsterdam16/08/2023 
Jakarta24/03/2024 
Beijing6/06/2024 
Istanbul12/06/2024 
Singapore7/08/2024 
Mexico City21/08/2024 
Sao Paulo28/08/2024 
Dubai21/09/2024 
Bangkok28/10/2024 

 

Using the table and slicer above as an example, my card here would return 9 current destinations. That's the 12 that have been launched between June 1, 2021 and March 11, 2024, minus the three that have been ceased (Tokyo, NYC, Shanghai).

 

Thank you for your help.

Al

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Al_Padrini ,

Please try this:

Measure = 
VAR __max_date = MAXX(ALLSELECTED('Date'[Date]),'Date'[Date])
VAR __result = COUNTROWS('Table') - CALCULATE(COUNTROWS('Table'),'Table'[Cease date]<=__max_date && 'Table'[Cease date]<> BLANK())
RETURN
__result

Output:

vcgaomsft_0-1710315204831.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

View solution in original post

4 REPLIES 4
Idrissshatila
Super User
Super User

Hello @Al_Padrini ,

 

use the following measure 

Measure = CALCULATE(COUNT('Table'[City name]),'Table'[Cease date] = BLANK())

 

Idrissshatila_0-1710227470926.png

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi @Idrissshatila,

 

Thank you, but it looks like it calculates the rows that correspond to the conditions 'cities that have been launched' AND 'cease date is blank', hence subtracting the three cities that have been ceased regardless of the date range in the slicer. 

For example here, that should return 11 (12 that have been launched until Jan, 1 2024 minus NYC).

Al_Padrini_0-1710232389901.png

Thanks,
Al

Anonymous
Not applicable

Hi @Al_Padrini ,

Please try this:

Measure = 
VAR __max_date = MAXX(ALLSELECTED('Date'[Date]),'Date'[Date])
VAR __result = COUNTROWS('Table') - CALCULATE(COUNTROWS('Table'),'Table'[Cease date]<=__max_date && 'Table'[Cease date]<> BLANK())
RETURN
__result

Output:

vcgaomsft_0-1710315204831.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

Amazing, it worked. Thank you! 

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.