Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I hope you are all well,
I have a task to showcase mobility of certain individuals between 2 dates. These dates are from 2 date slicers. Basically, when the user selects a start and end date. They need to see whether the individual has either moved or stayed between those date selections.
This is the desired output on the "Test" column below:
If the date slection was between these two:
I have tried using the following DAX measure, but I seem to not get the correct Test outcomes:
Test =
VAR _maxdate = calculate(max(Table[date]),allselected(Table))
VAR _prevstatus = calculate(
lastnonblank(Table[status],
_maxdate),
allexcept(Table,Table[Emp]))
VAR _currentstatus = selectedvalue(Table[status])
RETURN
if( _currentstatus = _prevstatus, 0, 1)
This the current result:
Any help would be appreciated.
Regards,
Asa
Solved! Go to Solution.
Hi @bhanu_gautam , thank you so much for your solution. I did give it a try and it didn't give the correct answer at first. For the startdeptstatus measure, if included in table with all employees, it gave only one value for everything. I added a step to isolate the employees:
VAR _mindate = calculate(min(table[date]),allselected(table))
VAR _start = calculate(max(table[status]),
table[date] = _mindate,
table[emp] = max(table[emp]),
allselected(table))
VAR _end = calculate(max(table[status]),
table[date] = max(table[date]),
table[emp] = max(table[emp]))
RETURN
if( _start = _end, "here", "moved")
Regards,
Asa
@asa70 Create two measures to capture the department status at the start and end dates.
Compare these statuses to determine if the individual has moved or stayed.
StartDeptStatus =
CALCULATE(
FIRSTNONBLANK(Table[Dept], 1),
FILTER(
Table,
Table[Date] = MINX(ALLSELECTED(Table), Table[Date])
)
)
EndDeptStatus =
CALCULATE(
FIRSTNONBLANK(Table[Dept], 1),
FILTER(
Table,
Table[Date] = MAXX(ALLSELECTED(Table), Table[Date])
)
)
Test =
IF(
[StartDeptStatus] = [EndDeptStatus],
"Here",
"Moved"
)
Proud to be a Super User! |
|
Hi @bhanu_gautam , thank you so much for your solution. I did give it a try and it didn't give the correct answer at first. For the startdeptstatus measure, if included in table with all employees, it gave only one value for everything. I added a step to isolate the employees:
VAR _mindate = calculate(min(table[date]),allselected(table))
VAR _start = calculate(max(table[status]),
table[date] = _mindate,
table[emp] = max(table[emp]),
allselected(table))
VAR _end = calculate(max(table[status]),
table[date] = max(table[date]),
table[emp] = max(table[emp]))
RETURN
if( _start = _end, "here", "moved")
Regards,
Asa
Hi @asa70 ,
Thanks for your response,
If you have found the resolution, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Chaithra E
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
80 | |
76 | |
60 | |
36 | |
33 |
User | Count |
---|---|
91 | |
60 | |
59 | |
49 | |
45 |