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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MarcoLopez
Advocate II
Advocate II

active workers

hi, i'm trying to display the number of workers today, I have a start date and a leaving date, so i need to show today's active workers and then with a slicer I want to show the same information by month, hope someone can help me.
example data: 

Worker IDstart dateleaving date
193111962003-06-152018-01-24
114244312005-07-262018-01-28
105743222009-09-172018-01-31
102406602001-10-03 
182648742001-07-28 
176929372004-10-02 
122985852011-07-03 

(date yyyy-mm-dd)

the ones with no leaving date, means that are still working on the company.
thank you 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @MarcoLopez,

 

Sample for your refernce, please check the following steps as below. If I misunderstood your request, kindly share your excepted result to me.

 

1. Crete a date table and one calculated column in it.

 

date = CALENDARAUTO()
YearMonth = YEAR('date'[Date]) &" " &FORMAT('date'[Date],"mmm")

2. Create two measures to get the result as we need.

 

today's active workers = 
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALL ( Table1 ), Table1[leaving date] = BLANK () )
)
by month = 
VAR mindate =
    CALCULATE ( MIN ( 'date'[Date] ), ALLSELECTED ( 'date'[YearMonth] ) )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            OR (
                Table1[start date] <= mindate
                    && Table1[leaving date] >= mindate,
                Table1[start date] <= mindate
                    && ISBLANK ( Table1[leaving date] )
            )
        )
    )

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @MarcoLopez,

 

Sample for your refernce, please check the following steps as below. If I misunderstood your request, kindly share your excepted result to me.

 

1. Crete a date table and one calculated column in it.

 

date = CALENDARAUTO()
YearMonth = YEAR('date'[Date]) &" " &FORMAT('date'[Date],"mmm")

2. Create two measures to get the result as we need.

 

today's active workers = 
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALL ( Table1 ), Table1[leaving date] = BLANK () )
)
by month = 
VAR mindate =
    CALCULATE ( MIN ( 'date'[Date] ), ALLSELECTED ( 'date'[YearMonth] ) )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            OR (
                Table1[start date] <= mindate
                    && Table1[leaving date] >= mindate,
                Table1[start date] <= mindate
                    && ISBLANK ( Table1[leaving date] )
            )
        )
    )

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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