Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello PowerBI Community,
I would like to use the new OFFSET function in order to find the difference between two dates, but within groups. I think the OFFSET (with partition) would be ideal but I cannot get it to work.
The data is as follows:
The output I am after is that;
Row 1 & 2, "Forecast - Baseline" should read the difference between the 23/5/2023 and 22/3/2023, i.e: x63 days
Row 3 & 4, "Forecast - Baseline" should read the difference between the 21/6/2024 and 21/6/2024, i.e: x0 days
Row 5 & 6, "Forecast - Baseline" should read the difference between the 24/10/2024 and 30/10/2024, i.e: x7 days
I have spent a number of days on this (I am just starting off with PowerBI) and the closest DAX I wrote was as follows;
I get a circular dependency error, amongst other errors with other methods.
I would prefer to attach the PowerBI file but can't seem to find how to do this?
I hope someone can help me, thanks very much.
Regards, Chris.
Solved! Go to Solution.
Hi,
Thank you for your message.
Please check the below picture and the attached pbix file.
If you want to see the results that are higher than zero, please try using ABS DAX function together.
Forecast-Baseline CC =
VAR _offsetresult =
MAXX (
OFFSET (
-1,
SUMMARIZE ( Matrix, Matrix[CIM #], Matrix[Date Dataset], Matrix[Date] ),
ORDERBY ( Matrix[Date Dataset], ASC ),
KEEP,
PARTITIONBY ( Matrix[CIM #] )
),
Matrix[Date]
)
VAR _offsetresultreverse =
MAXX (
OFFSET (
-1,
SUMMARIZE ( Matrix, Matrix[CIM #], Matrix[Date Dataset], Matrix[Date] ),
ORDERBY ( Matrix[Date Dataset], DESC ),
KEEP,
PARTITIONBY ( Matrix[CIM #] )
),
Matrix[Date]
)
RETURN
IF ( _offsetresult <> BLANK (), DATEDIFF ( _offsetresult, Matrix[Date], DAY ), DATEDIFF ( Matrix[Date], _offsetresultreverse, DAY ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi Jihwan_Kim,
That is great. Is there a way to have the values in the blank cells as well, i.e: 62 in Row 1 & Row 2, 0 in Row 3 & Row 4, etc. I expect I need this when I create the line chart.
Regards, Chris.
Hi,
Thank you for your message.
Please check the below picture and the attached pbix file.
If you want to see the results that are higher than zero, please try using ABS DAX function together.
Forecast-Baseline CC =
VAR _offsetresult =
MAXX (
OFFSET (
-1,
SUMMARIZE ( Matrix, Matrix[CIM #], Matrix[Date Dataset], Matrix[Date] ),
ORDERBY ( Matrix[Date Dataset], ASC ),
KEEP,
PARTITIONBY ( Matrix[CIM #] )
),
Matrix[Date]
)
VAR _offsetresultreverse =
MAXX (
OFFSET (
-1,
SUMMARIZE ( Matrix, Matrix[CIM #], Matrix[Date Dataset], Matrix[Date] ),
ORDERBY ( Matrix[Date Dataset], DESC ),
KEEP,
PARTITIONBY ( Matrix[CIM #] )
),
Matrix[Date]
)
RETURN
IF ( _offsetresult <> BLANK (), DATEDIFF ( _offsetresult, Matrix[Date], DAY ), DATEDIFF ( Matrix[Date], _offsetresultreverse, DAY ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hello PowerBI community,
The solution above is correct (thanks Jihwan_Kim!), but in incorporating the real data I have uncovered another problem I am hoping I could get some help with.
The intent of this graph is to show the slip/gain or neutral status of project milestones (in reality there would be a lot more more than three).
The lines are now correctly being formatted if the milestone slips (red), stays the same/neutral (grey) or is brought forward/gain (green)
What is happening now is that if a date of a line moves past another line/dot, it splits up the line. The first picture is correct (with limited sample data), but if I move the end date of the red line past the 21/6/2024 (the grey dot) the line splits into two dots.
As an aside, if anyone can tell me how to upload the *.pbix file, I am happy to share it.
Thanks for your help.
Regards, Chris.
Amazing Jihwan_Kim, thank you so much for your help.
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
Forecast-Baseline CC =
VAR _offsetresult =
MAXX (
OFFSET (
-1,
SUMMARIZE ( Matrix, Matrix[CIM #], Matrix[Date Dataset], Matrix[Date] ),
ORDERBY ( Matrix[Date Dataset], ASC ),
KEEP,
PARTITIONBY ( Matrix[CIM #] )
),
Matrix[Date]
)
RETURN
IF ( _offsetresult <> BLANK (), DATEDIFF ( _offsetresult, Matrix[Date], DAY ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
20 | |
19 | |
13 | |
12 |
User | Count |
---|---|
41 | |
27 | |
23 | |
22 | |
22 |