Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi.
Please help me with this task:
I need to create a cumulative days (measure) and days between (measure). I need these measures to use them in a table visual.
Like this:
'cum_days' is the name of measure.
'days_between' is another measure that I need.
In this model, I have a date table with relationship with my principal table.
In Excel is so easy to do.
But in DAX I have tried so many ways and I can't.
Solved! Go to Solution.
Hi, @Rickstor
You can try the following methods.
Measure:
days_between =
DATEDIFF (
MAXX ( FILTER ( ALL ( 'Table' ), [Date] < SELECTEDVALUE ( 'Table'[Date] ) ), [Date] ),
SELECTEDVALUE ( 'Table'[Date] ),
DAY
)
cum_days = SUMX(FILTER(ALL('Table'),[Date]<=SELECTEDVALUE('Table'[Date])),[days_between])
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Rickstor
You can try the following methods.
Measure:
days_between =
DATEDIFF (
MAXX ( FILTER ( ALL ( 'Table' ), [Date] < SELECTEDVALUE ( 'Table'[Date] ) ), [Date] ),
SELECTEDVALUE ( 'Table'[Date] ),
DAY
)
cum_days = SUMX(FILTER(ALL('Table'),[Date]<=SELECTEDVALUE('Table'[Date])),[days_between])
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Rickstor
Running Total MEASURE =
ELSE
Running Total MEASURE =
CALCULATE ( [Total Sales], Date[Date] <= MAX ( Date[Date] ) )
You could create measures like
Cumulative days =
VAR MinDate =
CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR CurrentDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR Result =
DATEDIFF ( MinDate, CurrentDate, DAY )
RETURN
Result
Days between =
VAR CurrentDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR Dates =
ALLSELECTED ( 'Table'[Date] )
VAR PrevDate =
OFFSET ( -1, Dates, ORDERBY ( 'Table'[Date], DESC ) )
VAR Result =
DATEDIFF ( PrevDate, CurrentDate, DAY )
RETURN
Result
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |