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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
M_SBS_6
Helper V
Helper V

Count based on dates

Hi, I need to add some totals to a table based on dates. 

 

I have the following table

 

ID.     Cust.    Date_sent

  1.   Kevin. 20/08/2024
  2.   Barry.  20/08/2024
  3.   Louise 21/08/2024

 

What I need is another column to see how many letters have been sent out within 6 months post and including today from date_sent.

 

The other column fields needed would be resp_date (the 6 month period) and count of resp_ID

 

So my table would look something like

 

ID.     Cust.    Date_sent.    Lettervol

  1.   Kevin.  20/08/2024.     2
  2.   Barry.  20/08/2024.     1
  3.   Louise 21/08/2024.     7

 

Any idea what measure to use please?

 

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hello, @M_SBS_6 ,

given you want physical column, perhaps you can do it in DAX, even tho I would recommend having this as a measure.

the dim table:

vojtechsima_0-1730913660706.png

lettervol = 
CALCULATE(
    COUNTROWS('fact'),
    DATESINPERIOD('calendar'[Date], dim[Date_sent],-6,MONTH)
)

 

vojtechsima_1-1730913681601.png

fact:

vojtechsima_2-1730913690316.png


Calendar is extra, I recommend having it as well.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

View solution in original post

1 REPLY 1
vojtechsima
Super User
Super User

Hello, @M_SBS_6 ,

given you want physical column, perhaps you can do it in DAX, even tho I would recommend having this as a measure.

the dim table:

vojtechsima_0-1730913660706.png

lettervol = 
CALCULATE(
    COUNTROWS('fact'),
    DATESINPERIOD('calendar'[Date], dim[Date_sent],-6,MONTH)
)

 

vojtechsima_1-1730913681601.png

fact:

vojtechsima_2-1730913690316.png


Calendar is extra, I recommend having it as well.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.