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

Calculated Column for sum between two dates

All,

 

I have a very simple data set with the following columns:

 

UserID

Week Ending

Week Ending - 28 Days (a calculated column that takes the week ending and subtracts 28 days)

Week Ending - 364 Days (a calculated column that takes the week ending and subtracts 364 days)

Subtotal Sales

 

I am looking to create a calculated column, not a measure, that takes the sum of the subtotal sales between two dates: Week Ending -364 Days and Week Ending -28 days for each user ID, and puts it in a calculated column on each row.

 

I'm struggling with the DAX for this - can anyone help?

 

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @jackj 

you can try this,

Calculated Column = CALCULATE(SUM('Table'[Subtotal Sales]),FILTER(ALL('Table'),EARLIER('Table'[Week Ending])<'Table'[Week Ending - 28 Days ]&&EARLIER('Table'[Week Ending])>='Table'[Week Ending - 364 Days]))

result

vxiaotang_0-1630315675899.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @jackj 

Have you solved this problem? If yes, could you kindly accept the answer helpful as the solution (or kindly share your solution ). so the others can find it more quickly.
really appreciate!
Any question, please let me know. Looking forward to receiving your reply.


Best Regards,
Community Support Team _Tang

v-xiaotang
Community Support
Community Support

Hi @jackj 

you can try this,

Calculated Column = CALCULATE(SUM('Table'[Subtotal Sales]),FILTER(ALL('Table'),EARLIER('Table'[Week Ending])<'Table'[Week Ending - 28 Days ]&&EARLIER('Table'[Week Ending])>='Table'[Week Ending - 364 Days]))

result

vxiaotang_0-1630315675899.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @jackj 

 

It'd be better if you share sample of your data in a table format here, but please try this measure:

Sum = calculate(sum(table[Subtotal Sales]),filter(all(table),table[Week Ending]>=table[Week Ending - 364 Days]&&table[Week Ending]<=table[Week Ending - 28 Days]))

 

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

Appreciate your Kudos VahidDM_0-1629940651052.png !!

 

 

 

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.