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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
CJMolin
Helper II
Helper II

Calculate an aggregated sum with 2 dynamic ref dates (calculated column)

Hello!
I am a new member to this forum but been browsing the topics quite frequently since i started to use the DAX language. Unfortunately I’ve now got stuck and would love to reach out to you and see if there are any solution(s) to my problem.

I am having a table with a datestamp which I want to use dynamically in order to calculate how many contracts that has been sent out during this dynamic period of time (as a calculated column, not a measure).
Eg. I want to sum how many contracts has been sent out between StartDt and EndDt relative to the Date shown in Table 1.


This is the data I have

Table 1

DateContract (1/0)CalculatedColumn
2017-05-011 
2017-05-011 
2017-05-070 
2017-05-091 


Table 2

Date (key)StartDt (-120 days from Date)EndDt (-30 days from Date)
2017-05-012017-01-012017-04-01
2017-05-022017-01-022017-04-02
2017-05-032017-01-032017-04-03
etc......


The DAX-expression used to far is:

=CALCULATE(SUM(DecisionFilter[DocsCustomer (1/0)]);FILTER(ALL(DecisionFilter);DecisionFilter[DateDocsCustomer]<=MAX(DecisionFilter[DateDocsCustomer]))) which only generated how many Contracts that has been sent out in total..

Please help me!
Thank you very much in advance,
CJ

1 ACCEPTED SOLUTION
CJMolin
Helper II
Helper II

If this would help anyone the answer to my request is the following

 

=CALCULATE(SUM(DecisionFilter[DocsCustomer (1/0)]);FILTER(DecisionFilter;DecisionFilter[DateAnswerLender]>=EARLIER(DecisionFilter[DateAnswerLender])-120&&DecisionFilter[DateAnswerLender]<=EARLIER(DecisionFilter[DateAnswerLender])-30&&DecisionFilter[ProductId]=EARLIER(DecisionFilter[ProductId])))

View solution in original post

5 REPLIES 5
CJMolin
Helper II
Helper II

If this would help anyone the answer to my request is the following

 

=CALCULATE(SUM(DecisionFilter[DocsCustomer (1/0)]);FILTER(DecisionFilter;DecisionFilter[DateAnswerLender]>=EARLIER(DecisionFilter[DateAnswerLender])-120&&DecisionFilter[DateAnswerLender]<=EARLIER(DecisionFilter[DateAnswerLender])-30&&DecisionFilter[ProductId]=EARLIER(DecisionFilter[ProductId])))
CJMolin
Helper II
Helper II

Hello!
I am a new member to this forum but been browsing the topics quite frequently since i started to use the DAX language. Unfortunately I’ve now got stuck and would love to reach out to you and see if there are any solution(s) to my problem.

I am having a table with a datestamp which I want to use dynamically in order to calculate how many contracts that has been sent out during this dynamic period of time (as a calculated column, not a measure).
Eg. I want to sum how many contracts has been sent out between StartDt and EndDt relative to the Date shown in Table 1.


This is the data I have

Table 1

DateContract (1/0)CalculatedColumn
2017-05-011 
2017-05-011 
2017-05-070 
2017-05-091 


Table 2

Date (key)StartDt (-120 days from Date)EndDt (-30 days from Date)
2017-05-012017-01-012017-04-01
2017-05-022017-01-022017-04-02
2017-05-032017-01-032017-04-03
etc......


The DAX-expression used to far is:

=CALCULATE(SUM(DecisionFilter[DocsCustomer (1/0)]);FILTER(ALL(DecisionFilter);DecisionFilter[DateDocsCustomer]<=MAX(DecisionFilter[DateDocsCustomer]))) which only generated how many Contracts that has been sent out in total..

Please help me!
Thank you very much in advance,
CJ

Hi @CJMolin,

Please try @Greg_Deckler posted formula. If you have not resolved your issue, you'd better post the sample table. For the given tables, I am unable to reproduce it.

Thanks,
Angelia

Something like this:

 

Column = CALCULATE(COUNT(Orders[OrderNo]),FILTER(RELATEDTABLE(Orders),Orders[StartDate]<='Calendar'[Date] && Orders[EndDate]>='Calendar'[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...

Hello @Greg_Deckler and @v-huizhn-msft

 

Thank you very much for your effors. Unfortunately the given expression only gives me what I already have accomplished to get, and that is not a cumulative sum during the time frame wanted. Maybe I was unclear in my request. I therefor attach a link with an excel-sheet (with the table both in excel and powerpivot) http://www.filedropper.com/examplehelpdax I also attach a simple picture with the explanation.

 

If you want me to provide you the examples in some other way, please let me know.

 

I would still really much appreciate your help, 

Thank you very much in advance,

Chelpdax.png

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.