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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Help With Dax

Hi Power Users,

 

I'm learning Power BI and trying to implement the below.

 

I have a table that contains ID,Start date and end date column as below.

 

IDStart dateEnd date
112/31/20196/1/2020
212/1/20194/20/2020
36/10/201912/31/2019
41/2/20202/22/2020
51/3/20203/18/2020
61/4/20203/19/2020
77/10/20195/20/2020
1012/31/20196/21/2020
114/2/20203/22/2020

 

And i have calender date table and have relationship between these 2 table. Start date to date(Active relationship) and end date to date(inactive relationship). 

 

I have slicer on calender date.

 

If the user select the a date range from 12/31/2019 to 05/31/2020. The table should caluclate number of ID's. Start date>=12/31/2019 and end date <=05/31/2020.

 

I need out like below.

 

Output  
IDStart dateEnd date
112/31/20196/1/2020
41/2/20202/22/2020
51/3/20203/18/2020
61/4/20203/19/2020
114/2/20203/22/2020

 

Count Of ID: 5

 

Please  help.

 

Thanks,

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous ,

Try

Measure =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = maxx(ALLSELECTED('Date'),'Date'[Date])
return
calculate(count(Table[ID]), filter(all(Table), Table[Start date]>=_min && Table[Start date]<=_max ))

 

or

 

Measure =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = maxx(ALLSELECTED('Date'),'Date'[Date])
return
calculate(count(Table[ID]), filter((Table), Table[Start date]>=_min && Table[Start date]<=_max ), crossfilter(Table[Start date],'Date'[Date],none)
, crossfilter(Table[End date],'Date'[Date],none))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi @Anonymous,

You can try to use the following measure formula to get the row count in selected ranges:

Measure = 
CALCULATE (
    COUNT ( Test[ID] ),
    FILTER (
        ALLSELECTED ( Test ),
        COUNTROWS (
            INTERSECT (
                CALENDAR ( Test[Start date], Test[End date] ),
                ALLSELECTED ( 'Calendar'[Date] )
            )
        ) > 0
    )
)

Notice: it seems not works on your sample data due to some records has the wrong date range. (start date over end date)
Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

You can try to use the following measure formula to get the row count in selected ranges:

Measure = 
CALCULATE (
    COUNT ( Test[ID] ),
    FILTER (
        ALLSELECTED ( Test ),
        COUNTROWS (
            INTERSECT (
                CALENDAR ( Test[Start date], Test[End date] ),
                ALLSELECTED ( 'Calendar'[Date] )
            )
        ) > 0
    )
)

Notice: it seems not works on your sample data due to some records has the wrong date range. (start date over end date)
Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous ,

Try

Measure =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = maxx(ALLSELECTED('Date'),'Date'[Date])
return
calculate(count(Table[ID]), filter(all(Table), Table[Start date]>=_min && Table[Start date]<=_max ))

 

or

 

Measure =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = maxx(ALLSELECTED('Date'),'Date'[Date])
return
calculate(count(Table[ID]), filter((Table), Table[Start date]>=_min && Table[Start date]<=_max ), crossfilter(Table[Start date],'Date'[Date],none)
, crossfilter(Table[End date],'Date'[Date],none))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Tahreem24
Super User
Super User

Just create measure like below:

Count of ID= Count(Table[IDcolumn])

And select the date range from slicer and see the result.

If this not helped you so please share the screenshot.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI 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.

Top Solution Authors