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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
msuser48
Helper I
Helper I

Count the SUM of a column GROUPED BY id, and sorted by year

I have this table:

RowId
IdStartDate
MailDateTrips
1
12019-11-20
2020-11-204
2
12019-11-20
2020-12-101
3
1
2019-11-20
2022-12-103
4
22018-11-20
2021-01-016
5
22018-11-202021-02-027
6
32019-01-012020-01-012
7
32019-01-01
2022-05-052
8
32019-01-01
2022-06-09

3

9
4
2015-01-01
2019-01-01

2

 

What I need to do:

I need the SUM of Trips made after each year since each Ids StartDate.

 

The output needs to be this table, which would look like this for the above table:

YearsPassedSinceStartDate (0-5 years is fixed interval)Amount (this will be our calculated column)
00
17
213
38
42
50

For example, for YearsPassedSinceStartDate with the value "1", we know that the amount is = 7.

- Why? Because RowId 1, 2 and 6's DateDiff between MailDate and StartDate is 1 year. And SUM of their trips is 4+1+2 = 7.

 

How do I produce the above table's calculated "Amount" column like this?

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@msuser48 

you can create a column

Column = int( DATEDIFF('Table'[StartDate],'Table'[MailDate],month)/12)

create a year table

and create a measure

Measure = sumx(FILTER('Table',max('Table (2)'[year])='Table'[Column]),'Table'[Trips])+0

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@msuser48 

you can create a column

Column = int( DATEDIFF('Table'[StartDate],'Table'[MailDate],month)/12)

create a year table

and create a measure

Measure = sumx(FILTER('Table',max('Table (2)'[year])='Table'[Column]),'Table'[Trips])+0

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.