Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
asa70
Frequent Visitor

Identifying Status Change Between 2 Date Selections

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:

asa70_0-1743489350880.png

 

If the date slection was between these two:

 

asa70_2-1743490128827.png

asa70_3-1743490169588.png

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:

asa70_1-1743490000244.png

 

Any help would be appreciated.

 

Regards,

Asa

1 ACCEPTED 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

View solution in original post

3 REPLIES 3
bhanu_gautam
Super User
Super User

@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"
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






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


Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.