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
Anonymous
Not applicable

Compare with previous months with criteria

Hi All,

 

I have 3 columns

 

1. Employee ID

2. Time Found :- Values( Yes, No)

3. Date

 

I would like to get a count of employees whose current month Time Found is No when compared the same employees whose Time Found value was Yes last month.

 

Hopefully i was able to explain my requirement

 

Let me try an example

 

Employee ID, Time Found, Date

11 , No,  08/01/2018

12,  Yes,  08/01/2018

13,  No,  08/01/2018

11,  Yes,  07/01/2018

12 , Yes,  07/01/2018

13,  Yes,  07/01/2018

 

My Count would be 2, since employee id 11 & 13 Time Found is No this month and Yes for last month

 

Thanks for your help in advance

 

Regards,

Sandeep

 

 

1 ACCEPTED SOLUTION

@Anonymous

 

Try this MEASURE as well

 

Measure =
VAR Currentmonth =MONTH ( MAX ( Table1[ Date] ) )
VAR Currentyear =YEAR ( MAX ( Table1[ Date] ) )
VAR EmployeesCurrentMonth =
    CALCULATETABLE (
        VALUES ( Table1[Employee ID] ),
        MONTH ( Table1[ Date] ) = Currentmonth
            && YEAR ( Table1[ Date] ) = Currentyear,
        Table1[ Time Found] = "No"
    )
VAR EmployeesPreviousmonth =
    CALCULATETABLE (
        VALUES ( Table1[Employee ID] ),
        MONTH ( Table1[ Date] )
            = Currentmonth - 1
            && YEAR ( Table1[ Date] ) = Currentyear,
        Table1[ Time Found] = "Yes"
    )
RETURN
    CONCATENATEX (
        INTERSECT ( EmployeesCurrentMonth, EmployeesPreviousmonth ),
        [Employee ID],
        ", "
    )

comparee.png


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2

You need to understand Time Intelligence in Power BI. My article will help you.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

@Anonymous

 

Try this MEASURE as well

 

Measure =
VAR Currentmonth =MONTH ( MAX ( Table1[ Date] ) )
VAR Currentyear =YEAR ( MAX ( Table1[ Date] ) )
VAR EmployeesCurrentMonth =
    CALCULATETABLE (
        VALUES ( Table1[Employee ID] ),
        MONTH ( Table1[ Date] ) = Currentmonth
            && YEAR ( Table1[ Date] ) = Currentyear,
        Table1[ Time Found] = "No"
    )
VAR EmployeesPreviousmonth =
    CALCULATETABLE (
        VALUES ( Table1[Employee ID] ),
        MONTH ( Table1[ Date] )
            = Currentmonth - 1
            && YEAR ( Table1[ Date] ) = Currentyear,
        Table1[ Time Found] = "Yes"
    )
RETURN
    CONCATENATEX (
        INTERSECT ( EmployeesCurrentMonth, EmployeesPreviousmonth ),
        [Employee ID],
        ", "
    )

comparee.png


Regards
Zubair

Please try my custom visuals

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.