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
bharukc
Helper I
Helper I

Calculate cumulative count based of dates from two different columns

Below is my table

ID

Idcompletion_dateresult_date
11/3/20173/3/2017
22/5/20178/5/2018
34/7/20176/8/2017
48/27/201710/26/2019
54/3/20189/8/2019
69/8/20188/7/2019
710/12/201911/24/2019
87/8/20199/20/2020
98/9/201911/26/2020
1011/23/201912/31/2020
1112/16/20193/4/2020
121/3/20202/5/2020

 

Below should be my result table. 

1st day of each quarter of completion date1 year ahead of each quarter of completion dateCumulative Count = count number of ids whose (completion_date < 1st day of each quarter of completion_date) && result_date < 1st day of each quarter of completion_date + 1 year)
1/1/20171/1/20180
4/1/20174/1/20181
7/1/20177/1/20182
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Picture1.png

 

New Table = 
VAR newtable =
    ADDCOLUMNS (
        Data,
        "@quarter_start",
            DATE ( YEAR ( Data[completion_date] ), ROUNDUP ( MONTH ( EOMONTH ( Data[completion_date], -1 ) + 1 ) / 3, 0 ) * 3 - 2, 1 ),
        "@oneyearlater",
            DATE ( YEAR ( Data[completion_date] ) + 1, ROUNDUP ( MONTH ( EOMONTH ( Data[completion_date], -1 ) + 1 ) / 3, 0 ) * 3 - 2, 1 )
    )
VAR quarterstart_oneyearlater =
    SUMMARIZE ( newtable, [@quarter_start], [@oneyearlater] )
VAR addcountcolumn =
    ADDCOLUMNS (
        quarterstart_oneyearlater,
        "@count",
            COUNTROWS (
                FILTER (
                    Data,
                    Data[completion_date] < [@quarter_start]
                        && Data[result_date] < [@oneyearlater]
                )
            ) + 0
    )
RETURN
    addcountcolumn

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Picture1.png

 

New Table = 
VAR newtable =
    ADDCOLUMNS (
        Data,
        "@quarter_start",
            DATE ( YEAR ( Data[completion_date] ), ROUNDUP ( MONTH ( EOMONTH ( Data[completion_date], -1 ) + 1 ) / 3, 0 ) * 3 - 2, 1 ),
        "@oneyearlater",
            DATE ( YEAR ( Data[completion_date] ) + 1, ROUNDUP ( MONTH ( EOMONTH ( Data[completion_date], -1 ) + 1 ) / 3, 0 ) * 3 - 2, 1 )
    )
VAR quarterstart_oneyearlater =
    SUMMARIZE ( newtable, [@quarter_start], [@oneyearlater] )
VAR addcountcolumn =
    ADDCOLUMNS (
        quarterstart_oneyearlater,
        "@count",
            COUNTROWS (
                FILTER (
                    Data,
                    Data[completion_date] < [@quarter_start]
                        && Data[result_date] < [@oneyearlater]
                )
            ) + 0
    )
RETURN
    addcountcolumn

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.