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
imy
Helper I
Helper I

Cross Tables

Hi,

 

I have created a crossjoin table to see how many employees are active per year in our company:

Crosstable Emp/year2 = FILTER(CROSSJOIN('All Employee Details','Date'),'Date'[Date]>='All Employee Details'[Contract Start Date]&&'Date'[Date]<='All Employee Details'[Contract End Date]).
 
However, when I create the bar chart is not taking into consideration the permanent employees as they dont have a Contract End Date (is blank)
How can I go around this?
 
Many thanks in advance for your help!
Imy
 
4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi @imy 

Just try this formula:

Crosstable Emp/year2 = 
FILTER (
    CROSSJOIN ( 'All Employee Details', 'Date' ),
    'Date'[Date] >= 'All Employee Details'[Contract Start Date]
       -- && 'Date'[Date] <= 'All Employee Details'[Contract End Date]
&& 'Date'[Date] <= IF(ISBLANK('All Employee Details'[Contract End Date]),TODAY(),'All Employee Details'[Contract End Date])
)

or

Crosstable Emp/year2 = 
FILTER (
    CROSSJOIN ( 'All Employee Details', 'Date' ),
    'Date'[Date] >= 'All Employee Details'[Contract Start Date]
       -- && 'Date'[Date] <= 'All Employee Details'[Contract End Date]

       &&'Date'[Date] <= IF(ISBLANK('All Employee Details'[Contract End Date]),MAX('Date'[Date]),'All Employee Details'[Contract End Date])
)

 

Regards,

Lin

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

Dear Lin,

 

I used this formula as I think is a great idea to put all permanent staff with end date today (this way they are taken into consideration in my bar chart);

Crosstable Emp/year2 = 
FILTER (
    CROSSJOIN ( 'All Employee Details', 'Date' ),
    'Date'[Date] >= 'All Employee Details'[Contract Start Date]
       -- && 'Date'[Date] <= 'All Employee Details'[Contract End Date]
&& 'Date'[Date] <= IF(ISBLANK('All Employee Details'[Contract End Date]),TODAY(),'All Employee Details'[Contract End Date])
)

Crosstable Emp/year2 = FILTER ( CROSSJOIN ( 'All Employee Details', 'Date' ), 'Date'[Date] >= 'All Employee Details'[Contract Start Date] -- && 'Date'[Date] <= 'All Employee Details'[Contract End Date] && 'Date'[Date] <= IF(ISBLANK('All Employee Details'[Contract End Date]),TODAY(),'All Employee Details'[Contract End Date]) )

 

However, The Contract End Date is still empty, why is this happening?

 

Many thanks

Imy

hi @imy 

It should work well, try to remove these code in the formula

-- && 'Date'[Date] <= 'All Employee Details'[Contract End Date]

 

Crosstable Emp/year2 =
FILTER (
    CROSSJOIN ( 'All Employee Details', 'Date' ),
    'Date'[Date] >= 'All Employee Details'[Contract Start Date]
        && 'Date'[Date]
            <= IF (
                ISBLANK ( 'All Employee Details'[Contract End Date] ),
                TODAY (),
                'All Employee Details'[Contract End Date]
            )
)

For example:

1.JPG

Result:

2.JPG

 

Do you mean that you want the Contract End Date column for ID 2 is not blank? 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
VasTg
Memorable Member
Memorable Member

@imy 

 

Try this.

 

FILTER(CROSSJOIN('All Employee Details','Date'),'Date'[Date]>='All Employee Details'['Contract Start Date']&&'Date'[Date]<='All Employee Details'['Contract End Date']||('Date'[Date]>='All Employee Details'['Contract Start Date']&&ISBLANK('All Employee Details'['Contract End Date'])))
 
If it works, hit the answered button.

 

Connect on LinkedIn

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.