Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi everyone,
I have a sample dataset that looks like this,
and a sample pbi template that looks like this:
And here is what I am trying to achieve:
As you can see in the pbi template, there is a slicer for Project Stage and multiple cards to show different information. The cards that are most relevant to this question is Project Stage, DateDiff Prev Stage, and the Stage slicer.
For the DateDiff Prev Stage, currently it is showing the DateDiff between Stage 2 and Stage 1. I did that by creating a variable for each of the stages and then simply returning the datediff between the 2 to be displayed in the card.
What I ultimately want to do is make this change dynamic. I want to create a measure that when I choose a stage on the slicer, the measure calculates the datediff between my current selection stage and whatever directly previous stage relative to the current selection is. As of now, I have no idea how I can achieve that.
Any help is appreciated. Thanks in advance
Solved! Go to Solution.
Hi rjsidek,
I want to check the logic with you, when you choose stage 1, which previous date of it?Shouls it show blank? When you choose 2, it should compare 1 and 2 . You could refer to my sample for details to see whether it work or not.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rjsidek ,
Please try this:
Previous Date =
IF (
'Table'[Stage Number] > 1,
CALCULATE (
MAX ( 'Table'[Date] ),
ALLEXCEPT ( 'Table', 'Table'[Company] ),
'Table'[Stage Number]
= EARLIER ( 'Table'[Stage Number] ) - 1
)
)
Datediff =
DATEDIFF ( 'Table'[Previous Date], 'Table'[Date], DAY )
Hi @danextian ,
I tried doing it how you suggested but it does not seem to be working. This is what it shows currently:
I provided the tables visualization to show what the measure currently shows. As you can see, the datediff is just showing blanks, and I am not quite sure why.
These are the codes I used to create the 2 calculated columns
Previous Date =
IF (
Table1[Stage Number] > 1,
CALCULATE (
MAX ( Table1[Date of Event] ),
ALLEXCEPT ( Table1, Table1[Company Name] ),
Table1[Stage Number]
= EARLIER ( Table1[Stage Number] ) - 1
)
)
Datediff =
DATEDIFF ( Table1[Previous Date], Table1[Date of Event], MONTH )
Any ideas how to correct this?
Hi rjsidek,
I want to check the logic with you, when you choose stage 1, which previous date of it?Shouls it show blank? When you choose 2, it should compare 1 and 2 . You could refer to my sample for details to see whether it work or not.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Can you please post a screenshot of the data view filtered to the stage and company in your screenshot similar to image below?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 40 | |
| 36 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 69 | |
| 38 | |
| 34 | |
| 23 |