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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Harmen
Regular Visitor

Dax

Hello, I have a dax question, how to countrows where filter is a reference date between to dates. With the next dax expression i count rows where the reference date (today) is between the startingdate and enddate. How can i make this dynamic? Not today but i want to use random dates? 

 

Peildatum =
CALCULATE (
    COUNTROWS ( 'Uitkeringsgegevens' ),
    FILTER (
        'Uitkeringsgegevens',
        (
            'Uitkeringsgegevens'[startdate] <= TODAY()
                && 'Uitkeringsgegevens'[Enddate] > TODAY()
        )
    )
)
 
Do i need a dimdate table and so yes, how to use it?
Can someone help me?
 
Kind regards,
Harmen
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Harmen ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create adate dimension table as below and apply the date field of this date dimension table on the slicer

Date = CALENDARAUTO()

2. Update a measure as below to get it:

Peildatum =
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Uitkeringsgegevens' ),
        FILTER (
            'Uitkeringsgegevens',
            ( 'Uitkeringsgegevens'[startdate] <= _seldate
                && 'Uitkeringsgegevens'[Enddate] > _seldate )
        )
    )

yingyinr_1-1671607949552.png

If the above one can't help you get the desired result, please provide some raw data in your table 'Uitkeringsgegevens' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Harmen ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create adate dimension table as below and apply the date field of this date dimension table on the slicer

Date = CALENDARAUTO()

2. Update a measure as below to get it:

Peildatum =
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Uitkeringsgegevens' ),
        FILTER (
            'Uitkeringsgegevens',
            ( 'Uitkeringsgegevens'[startdate] <= _seldate
                && 'Uitkeringsgegevens'[Enddate] > _seldate )
        )
    )

yingyinr_1-1671607949552.png

If the above one can't help you get the desired result, please provide some raw data in your table 'Uitkeringsgegevens' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

nick_potts
New Member

You want to replace 

TODAY()

With a random date? Or will a user be selecting the start and end date? I think knowing the end goal would help.

Thé user select a date and where the selected date is between the startdate and enddate i want to count the row.

If you do want to replace TODAY() with another date, are those dates different or will they always be the same?

The dates will always be the same.

Do you already have a date table? If so, drop that date on the page as a slicer and change TODAY() to 

SELECTEDVALUE('Dim Date'[Date])
Bifinity_75
Solution Sage
Solution Sage

Hi @Harmen , try add "ALL" to your dax expression:

 

Peildatum =
CALCULATE (
    COUNTROWS ( 'Uitkeringsgegevens' ),
    FILTER (ALL( 'Uitkeringsgegevens'),
        (
            'Uitkeringsgegevens'[startdate] <= TODAY()
                && 'Uitkeringsgegevens'[Enddate] > TODAY()
        )
    )
)
 
Best Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.