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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
ninakarsa
Helper II
Helper II

count between dates by product

Hi All,

I need a bit of help, trying to solve the following problem. I have 'Table A' with products with start and end dats, i have 'Table B' with sales by product. I want to create a table c as below which shows the the number of times a product appears in table a where the sales date from table b is between the start date and end date in table a.

I am using the following but it returns the results ignoring the product, results shown in table d:

 

Number= COUNTAX(filter(('table 1 (2)'),'table 1 (2)'[product] = [Product] && [sales date] >= 'table 1 (2)'[start Date]&& [sales date] <= 'table 1 (2)'[end date]),[Product])

 

 

 

 

Table A:

productstart Dateend date
long01/03/201908/03/2019
long01/03/201908/03/2019
medium01/03/201908/03/2019
medium01/03/201908/03/2019
medium01/03/201908/03/2019
short08/03/201915/03/2019
long08/03/201915/03/2019
short12/03/201919/03/2019
medium08/03/201915/03/2019
medium15/03/201922/03/2019

 

Table b

sales dateamountProduct
03/03/2019120long
03/03/2019150long
10/03/2019165short
17/03/2019195 
24/03/2019210 
31/03/2019240 

 

Table C:

sales dateamountProductnumber
03/03/2019120long2
03/03/2019150long2
10/03/2019165short1
17/03/2019195  
24/03/2019210  
31/03/2019240  

 

table d:

 

sales date amount Product number
3 March 2019120long5
3 March 2019150long5
10 March 2019165short3
17 March 2019195 2
24 March 2019210  
31 March 2019240  
2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

So I did the following. PBIX attached.

 

Table C = 
  ADDCOLUMNS(
      'Table B',
      "number",COUNTROWS(
          FILTER(
              'Table A',
              'Table B'[Product] = 'Table A'[product] && 
                'Table B'[sales date] >= 'Table A'[start Date] && 
                    'Table B'[sales date] <= 'Table A'[end date]
          )
      ))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

this works perfect. thank you

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

So I did the following. PBIX attached.

 

Table C = 
  ADDCOLUMNS(
      'Table B',
      "number",COUNTROWS(
          FILTER(
              'Table A',
              'Table B'[Product] = 'Table A'[product] && 
                'Table B'[sales date] >= 'Table A'[start Date] && 
                    'Table B'[sales date] <= 'Table A'[end date]
          )
      ))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

this works perfect. thank you

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.