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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kopek
Helper IV
Helper IV

Comparing two values in one column

Hi, I am having a strange isssue comparing two values from one column, one table.
Below you will find an example of my datasource.
I want to check if employee id in May = Employee id in April, and in this case for ID 6666 i want to obtain "NS", for ID 7777 "Leaver".

I have prepared few functions but it always gives me false result, meaning that it always says all ids are different.
The employee ID is a type text, i have converted it to numbers (not ideal...) but have not worked either...
Could you pleasehelp me and let me know what i have done wrongly ?


DateEmployee ID
01 May 20211111
01 April 20211111
01 May 20212222
01 April 20212222
01 May 20213333
01 April 20213333
01 May 20214444
01 April 20214444
01 April 20215555
01 May 20215555
01 May 20216666
01 April 20217777
01 May 20218888
01 April 20218888
01 May 20219999
01 April 20219999

 

 

I have tried following as a measure and as a column but the outcome alway was false...

Measure = 

Var MaxDate = MAX('People reports'[Source.Name.1])
Var EIDCurrent = CALCULATE(MAX('People reports'[Employee ID]),'People reports'[Source.Name.1] = MaxDate)
Var PrevMonth = MIN('People reports'[Source.Name.1])
Var EIDPrevMth = CALCULATE(MAX('People reports'[Employee ID]),'People reports'[Source.Name.1] = PrevMonth)
Return
IF(EIDCurrent = EIDPrevMth,0,1)
have also tried added new flags, different measures but nothing work...

 
Thanks in advance!
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Picture1.png

 

https://www.dropbox.com/s/5h0r4sm9xp268yv/kopek.pbix?dl=0 

 

 

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.


Go to My LinkedIn Page


View solution in original post

v-rzhou-msft
Community Support
Community Support

Hi @Kopek 

You need to create two Employee ID List in your measure and compare your values with the List in your measure.

Try this measure:

Measure = 
VAR _MAXDate = MAXX(ALL('People reports'),'People reports'[Date])
VAR _MINDate = MINX(ALL('People reports'),'People reports'[Date])
VAR _MaxPeopleList = SUMMARIZE(FILTER(ALL('People reports'),'People reports'[Date] = _MAXDate),'People reports'[Employee ID])
VAR _MinPeopleList = SUMMARIZE(FILTER(ALL('People reports'),'People reports'[Date] = _MINDate),'People reports'[Employee ID])
RETURN
SWITCH(TRUE(),AND(MAX('People reports'[Employee ID]) in _MaxPeopleList,MAX('People reports'[Employee ID]) in _MinPeopleList),"In Two Month",AND(MAX('People reports'[Employee ID]) in _MaxPeopleList,NOT(MAX('People reports'[Employee ID])) in _MinPeopleList),"NS","Leaver")

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Kopek 

You need to create two Employee ID List in your measure and compare your values with the List in your measure.

Try this measure:

Measure = 
VAR _MAXDate = MAXX(ALL('People reports'),'People reports'[Date])
VAR _MINDate = MINX(ALL('People reports'),'People reports'[Date])
VAR _MaxPeopleList = SUMMARIZE(FILTER(ALL('People reports'),'People reports'[Date] = _MAXDate),'People reports'[Employee ID])
VAR _MinPeopleList = SUMMARIZE(FILTER(ALL('People reports'),'People reports'[Date] = _MINDate),'People reports'[Employee ID])
RETURN
SWITCH(TRUE(),AND(MAX('People reports'[Employee ID]) in _MaxPeopleList,MAX('People reports'[Employee ID]) in _MinPeopleList),"In Two Month",AND(MAX('People reports'[Employee ID]) in _MaxPeopleList,NOT(MAX('People reports'[Employee ID])) in _MinPeopleList),"NS","Leaver")

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Jihwan_Kim
Super User
Super User

Picture1.png

 

https://www.dropbox.com/s/5h0r4sm9xp268yv/kopek.pbix?dl=0 

 

 

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.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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