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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jalalmn
Frequent Visitor

Filter in measure does not work properly exceptionally in the last year

Hi

I have created a measure that calculates the income in terms of year to date.
It works properly for all years in my data, but only in the last year the result is not correct. I have digged into my data and understood that it does not take into effect the last few days in the latest month (which is in May 2024). For previous years it the results of absolutely correct. Only in the year 2024 the results are wrong!

Why it works correctly for all years except for 2024?? why it misses the last few days?

GBV = VAR year_in_context = SELECTEDVALUE('Date'[Year])
      VAR month_in_focus = MONTH(TODAY())
      VAR day_in_focus = DAY(TODAY())
      VAR last_day = DATE(year_in_context, month_in_focus, day_in_focus)
      VAR first_day = DATE(year_in_context, 1, 1)
      VAR Result =  CALCULATE(
            SUM('bookings'[Price]),
                FILTER(
                'bookings',
                'bookings'[BookingDate] >= first_day &&
                'bookings'[BookingDate] <= last_day
                ))
    RETURN Result

Many thanks in advance for your help!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Jalalmn ,

 

Are you referring to a maximum date of the end of the current month .

You may consider using the following dax:

 

GBV
 = VAR year_in_context = SELECTEDVALUE('Date'[Year])
      VAR month_in_focus = MONTH(TODAY())
      VAR day_in_focus = DAY(TODAY())
      VAR last_day1 = DATE(year_in_context, month_in_focus, day_in_focus)  
      VAR last_day2 = EOMONTH(last_day1 ,0)
      VAR first_day = DATE(year_in_context, 1, 1)
      VAR Result =  CALCULATE(
            SUM('bookings'[Price]),
                FILTER(
                ALL('bookings'),
                'bookings'[BookingDate] >= first_day &&
                'bookings'[BookingDate] <= last_day2
                ))
    RETURN
Result

 

You can check to see if there are filters filtering that are causing the 2024 values to appear incorrectly or to see if the table-to-table relationships are connected correctly.

 

If the results don't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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
Jalalmn
Frequent Visitor

Hi Liu,

 

Late at night I understood where the problem come from 🙂

Actually I need ytd of income, not the income till the end of month. So it depends on the current day.

The problem was happening because my date table had stopped gettin updated to include the last few days into the dates 🙂

 

Many thanks anyway,

Jalal

Anonymous
Not applicable

Hi  @Jalalmn ,

 

Are you referring to a maximum date of the end of the current month .

You may consider using the following dax:

 

GBV
 = VAR year_in_context = SELECTEDVALUE('Date'[Year])
      VAR month_in_focus = MONTH(TODAY())
      VAR day_in_focus = DAY(TODAY())
      VAR last_day1 = DATE(year_in_context, month_in_focus, day_in_focus)  
      VAR last_day2 = EOMONTH(last_day1 ,0)
      VAR first_day = DATE(year_in_context, 1, 1)
      VAR Result =  CALCULATE(
            SUM('bookings'[Price]),
                FILTER(
                ALL('bookings'),
                'bookings'[BookingDate] >= first_day &&
                'bookings'[BookingDate] <= last_day2
                ))
    RETURN
Result

 

You can check to see if there are filters filtering that are causing the 2024 values to appear incorrectly or to see if the table-to-table relationships are connected correctly.

 

If the results don't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.