Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello. Please take a look at the table below:
Location | Period | Application | Date |
P1 | 1st | 1st application | 01/01/2025 |
P1 | 2nd | 1st application | 01/02/2025 |
P1 | 1st | 2nd application | 01/20/2025 |
P1 | 2nd | 2nd application | 01/21/2025 |
P2 | 1st | 1st application | 01/05/2025 |
P2 | 2nd | 1st application | 01/06/2025 |
P2 | 1st | 2nd application | 01/15/2025 |
P2 | 2nd | 2nd application | 01/19/2025 |
I need a column or measure that shows the difference (days) between the current application of the period and the most recent date of the last application at a given location of the period. It would look something like this:
Location | Period | Application | Date | Difference |
P1 | 1st | 1st application | 01/01/2025 | |
P1 | 2nd | 1st application | 01/02/2025 | |
P1 | 1st | 2nd application | 01/20/2025 | 19 |
P1 | 2nd | 2nd application | 01/21/2025 | 19 |
P2 | 1st | 1st application | 01/05/2025 | |
P2 | 2nd | 1st application | 01/06/2025 | |
P2 | 1st | 2nd application | 01/15/2025 | 10 |
P2 | 2nd | 2nd application | 01/19/2025 | 13 |
If this is the first application, it should show a null value. One thing to keep in mind is that this table is just an example. Sometimes, there will be 12 or more applications in the same location.
Solved! Go to Solution.
Hi @jobf ,
you can achieve your goal by this DAX measure:
Difference =
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentApplication = SELECTEDVALUE('Table'[Application])
VAR Location = SELECTEDVALUE('Table'[Location])
VAR PreviousApplicationMaxDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Location] = Location &&
'Table'[Application] <> CurrentApplication &&
'Table'[Date] < CurrentDate
)
)
RETURN
IF(
ISBLANK(PreviousApplicationMaxDate),
BLANK(),
DATEDIFF(PreviousApplicationMaxDate, CurrentDate, DAY)
)
Your output will look like this:
Remember a rule of thumb, integer is the most preferrable data type in PBI, namely good for data compression and calculation as well. Turn columns Period and Application to integer.
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
Remember a rule of thumb, integer is the most preferrable data type in PBI, namely good for data compression and calculation as well. Turn columns Period and Application to integer.
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
Hi @jobf ,
you can achieve your goal by this DAX measure:
Difference =
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentApplication = SELECTEDVALUE('Table'[Application])
VAR Location = SELECTEDVALUE('Table'[Location])
VAR PreviousApplicationMaxDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Location] = Location &&
'Table'[Application] <> CurrentApplication &&
'Table'[Date] < CurrentDate
)
)
RETURN
IF(
ISBLANK(PreviousApplicationMaxDate),
BLANK(),
DATEDIFF(PreviousApplicationMaxDate, CurrentDate, DAY)
)
Your output will look like this:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
70 | |
66 | |
50 | |
31 |
User | Count |
---|---|
116 | |
99 | |
75 | |
65 | |
40 |