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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Adam_Harris
Frequent Visitor

Count number of rows between Week Start Date & Week End Date

Hi,

I have a table with column Date (dd/mm/yyyy), Week Start Date , Week End date.

 

How do I count number of rows between Week Start Date & Week End Date just for year 2020.

 

Exp:-

Week Range                           Total Rows

______________                        _______________

 

6/1/2020 - 12/1/2020                    128

13/1/2020 - 19/1/2020                   122

 

 

Any ideas on how I could write a formula to achieve this?

1 ACCEPTED SOLUTION

Hi @Adam_Harris ,

 

You can try to use the DAX below to create a calculated column:

Column = CALCULATE(COUNTROWS(test),FILTER(test,EARLIER(test[Week Start Date])=test[Week Start Date]&&EARLIER(test[Week End Date])=test[Week End Date]))
test_countrows.PNG

 

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

View solution in original post

5 REPLIES 5
vivran22
Community Champion
Community Champion

Hello @Adam_Harris,

 

How you are defining the Week Range? Is it dynamic or static?

 

Regards,

Vivek

Week Range

Week Start Date = Date[Date] - WEEKDAY(Date[Date],2) + 1

 

Week End Date = Date[Date] - WEEKDAY(Date[Date],2) + 7

in a dynamic

Hi,

 

Perhaps you could try something like

 

 

Measure = 
CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        'Table'[Date]>= MIN('Table'[Week Start Date])
            && 'Table'[Date] <= MAX ('Table'[Week End Date])
))

 

 

Its give me result :

Week Start Date      Week End Date      Total Rows
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
17/2/2020                  23/2/2020               1
10/2/2020                  16/2/2020               1
10/2/2020                  16/2/2020               1
10/2/2020                  16/2/2020               1

 

 

But i'm expecting like this:

Week Start Date           Week End Date        Total Rows
17/2/2020                    23/2/2020                  18
10/2/2020                    16/2/2020                  21

 

Hi @Adam_Harris ,

 

You can try to use the DAX below to create a calculated column:

Column = CALCULATE(COUNTROWS(test),FILTER(test,EARLIER(test[Week Start Date])=test[Week Start Date]&&EARLIER(test[Week End Date])=test[Week End Date]))
test_countrows.PNG

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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