March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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?
Solved! Go to Solution.
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.
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
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
19 | |
17 | |
9 | |
5 |
User | Count |
---|---|
36 | |
29 | |
16 | |
15 | |
12 |