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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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