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,
is it possible to use a DATEDIFF formulas with values in different Rows and Fields(or another DAX formulas)?
For example, i 've the following Data:
ITEM | STATUS | DATE1 | DATE2 |
XXX | Receipt | 01/05/2021 | |
XXX | Delivery | 05/05/2021 | |
YYY | Receipt | 04/04/2021 | |
ZZZ | Receipt | 30/04/2021 | |
YYY | Delivery | 07/04/2021 | |
ZZZ | Delivery | 11/05/2021 |
The result that i need is the sum of the days difference by Item. In my exemple the result must be 18:
ITEM | DATE1 | DATE2 | RESULTS |
XXX | 01/05/2021 | 05/05/2021 | 4 |
YYY | 04/04/2021 | 07/04/2021 | 3 |
ZZZ | 30/04/2021 | 11/05/2021 | 11 |
RESULT: | 18 |
Is there a DAX formulas to achive this result?
Thanks in advance.
Hi, @DaniBi92
Please check the below picture and the sample pbix file's link down below.
All measures are in the sample b pbix file, and all steps are numbered in front of each measure.
https://www.dropbox.com/s/4lwg972lhq9ki9q/danibi.pbix?dl=0
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
@DaniBi92
You can create a DX table with the following code. Click New Table under the Modeling tab and paste the code given below, rename the table name as per yours.
Result Table =
ADDCOLUMNS(
ADDCOLUMNS(
VALUES(Table1[ITEM]),
"DATE1", CALCULATE(MIN(Table1[DATE1])),
"DATE2", CALCULATE(MIN(Table1[DATE2]))
),
"RESULT", DATEDIFF([DATE1],[DATE2],DAY)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@DaniBi92 See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |