cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Arne_MUC Frequent Visitor
Frequent Visitor

Filtering Data with DAX

Hi all,

I wish to filter data for employees (FTE) for a single month. DAX code as follows:

FTEACT202002:=CALCULATE(
      SUMX('Upload Sheet';[Total FTE]);
      FILTER('Upload Sheet';
       AND([Date of entry]<=DATE(2020;2;1);
        OR(
         ISBLANK([Date employee left]);
        [Date employee left]>=date(2020;2;1))
       )
      ))

Code works properly for almost all data sets, 2 sets show strange data:

 

Note-201191018.png

 

DAX code for April is similar to the February measure. Formats of relevant data fields is (of course) the same of all data sets. The only difference which appears to me is, that "date employee left" in a regular case is always end of month despite the 2 strange data sets where it is one within the month and one at the end of February in a leap year.

Thanks for any advice.

Arne

2 REPLIES 2
Super User IV
Super User IV

Re: Filtering Data with DAX

The formula seems fine. If possible please share a sample pbix file after removing sensitive information.

 

We need to April formula to check why it is not working.

 

Also, Try to use startofmonth(DATE[Date]) in place of date(2020,02,01) and see if works.

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.





Did I answer your question? Mark my post as a solution!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


Arne_MUC Frequent Visitor
Frequent Visitor

Re: Filtering Data with DAX

@amitchandakThanks for your contribution. Please see April formula as follows:

FTEACT202004:=CALCULATE(
      SUMX('Upload Sheet';[Total FTE]);
      FILTER('Upload Sheet';
       AND([Date of entry]<=DATE(2020;4;1);
        OR(
         ISBLANK([Date employee left]);
        [Date employee left]>=date(2020;4;1))
       )
      ))

Using STARTOFMONTH in the formula doesn't show any change in the result:

FTEACT202002:=CALCULATE(
      SUMX('Upload Sheet';[Total FTE]);
      FILTER('Upload Sheet';
       AND(STARTOFMONTH('Upload Sheet'[Date of entry])<=DATE(2020;2;1);
        OR(
         ISBLANK([Date employee left]);
        STARTOFMONTH('Upload Sheet'[Date employee left])>=date(2020;2;1))
       )
      ))

I cannot use STARTOFMONTH for the right section of the term (DATE(2020;1;1)) since I do not refer to a single date column. However, I use fixed dates (2020/1/1, 2020/2/1...) to filter the data. These measures are used as columns in a result table (as shown in the screenshot above). Any guess why it doesn't work? Thanks in advance.

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors