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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PdJogo
Frequent Visitor

Cycle to Date Calculation - difficulties on DAX Measure

Dear all,

 

I have been strugling with the production of a Cycle to Date (CTD) measure.

 

Context

I am working on a data model that is basically CRM data: a FactTable with interactions between customers and Sales Reps. This Sales Reps are organized by some territories and each Territory might have different Cycles (lets say I have 4 cycles per year in USA but 12 cycles per Year in India, for example). For this reason, the fact table contains the date of the interaction, the sales rep info and also the cycle key.

 

Difficulties being faced

I want to create a Field Days measure. This is somehow easy as it is a DistinctCountNoBlank of the DateKey I have in the FactTable. Although, my difficulty is when I want to see this Cycle to Date. Example:

 

- Cycle Table

Cycle         StartDate         EndDate          Territory

C1 2021     1 Jan 2021      30 Apr 2021       USA

C2 2021    1 May 2021      31 Aug 2021     USA

C1 2022    1 Jan 2022        31 Jan 2022      India

C2 2022     1 Feb 2022       28 Feb 2022     India

 

This table is connected to the fact table via a CycleKey. I want to be able to do a distinct count of the field days per cycle. Meaning that the following result should be obtained for USA:
                   Monthly Field Days         CTD Field Days
Jan 2022              21                                      21
Feb 2022             15                                      36

Mar 2022             15                                      51

Apr 2022             15                                      66

May 2022             15                                      15

Jun 2022             15                                      30

Jul 2022             15                                      45

Aug 2022             15                                      60


How can I do this?

Thanks in advance 🙂 

1 ACCEPTED SOLUTION

Hello Amit,

Thanks for your answer!
After checkig your answer and searching a little bit more, I find out this one: (17) Implementing running total from arbitrary dates in DAX - Unplugged #34 - YouTube

Guess this is more or less what I was looking for!

Thanks for your help 🙂 

View solution in original post

3 REPLIES 3
PdJogo
Frequent Visitor

Hello again,

Following the implementation of the solution in the video I mentioned, I am facing one other issue 😥

The measures I have only show values if I have date as a field into the visual.

For example:

- If I simply run the measure, without any time intelligence applied

PdJogo_0-1672361175222.png

- If I run the same measure but applying the time intelligence as follows (similar to the video), no value shows up:

VAR RefDate =
    MAX ( DimDate[Date] )
VAR LastReset = [Aux Last Reset]
VAR DatesToUse =
    DATESBETWEEN ( DimDate[Date], LastReset, RefDate )
VAR Result =
    CALCULATE ( SELECTEDMEASURE (), DatesToUse )
RETURN
    Result

 PdJogo_1-1672361277066.png

- Although, if I put there, for example, Month Year, it will show up the values:

PdJogo_2-1672361322562.png

 

Anyway I can, for example, put the behaviour into the time intelligence to "show always the latest date of the context when there is no date"?
Any insight you might have @amitchandak ?

Thanks in advance for your help! 😀

amitchandak
Super User
Super User

@PdJogo , Check one of two should help

 


Between Dates - Dates between
Measure way
Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM
https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

 

SCD
Guyinacube - https://www.youtube.com/watch?v=tKeaQpWynzg

https://www.youtube.com/watch?v=E1ZABKBpkdg

https://www.zartis.com/scd-implementation-with-temporal-tables-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello Amit,

Thanks for your answer!
After checkig your answer and searching a little bit more, I find out this one: (17) Implementing running total from arbitrary dates in DAX - Unplugged #34 - YouTube

Guess this is more or less what I was looking for!

Thanks for your help 🙂 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors