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 September 15. Request your voucher.

Reply
JonGunnar
Frequent Visitor

Total active contracts on two selected dates

I would like to get the number of active contracts on two specific selected dates in a date slicer. Based on a suggestion from radacad, Power BI From and To Date Filtering with One Slicer - RADACAD I have created two measures on contract table DatoStart and DatoSlutt (end). The date table is without relationship. KONTRRETUR is start date of contract. KONTROPPSEIINGDATO is end date.

 

The result is correct as shown below. 

 

DatoStart = var _rangeStart=FIRSTDATE('sheet1 (2)'[DATO]) return
IF(SELECTEDVALUE('Spørring2'[KONTRRETUR])<=_rangeStart && SELECTEDVALUE('Spørring2'[KONTROPPSEIINGDATO])>_rangeStart ,1,0)
 
DatoSlutt = var _rangeSlutt=LASTDATE('sheet1 (2)'[DATO]) return
IF(SELECTEDVALUE('Spørring2'[KONTRRETUR])<=_rangeSlutt && SELECTEDVALUE('Spørring2'[KONTROPPSEIINGDATO])>_rangeSlutt ,1,0)
 
JonGunnar_1-1655797591856.png

To get the total numbers for first date the following create the following measure:

CALCULATE(COUNTROWS('Spørring2'),FILTER('Spørring2','Spørring2'[DatoStart] = 1))
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @JonGunnar 

Thanks for reaching out to us.

>>to count total active contracts on two selected dates

vxiaotang_0-1656051309735.png

Please try this, create the 3 measures below,

selectedStart=minx(allselected('Date'),[date])

selectedEnd=maxx(allselected('Date'),[date])

count= calculate(countrows('Fact'),filter(all('Fact'),'Fact'[start date]>=[selectedStart] && 'Fact'[end date]<=[selectedEnd]))

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xiaotang
Community Support
Community Support

Hi @JonGunnar 

Thanks for reaching out to us.

>>to count total active contracts on two selected dates

vxiaotang_0-1656051309735.png

Please try this, create the 3 measures below,

selectedStart=minx(allselected('Date'),[date])

selectedEnd=maxx(allselected('Date'),[date])

count= calculate(countrows('Fact'),filter(all('Fact'),'Fact'[start date]>=[selectedStart] && 'Fact'[end date]<=[selectedEnd]))

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Kudoed Authors