Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
My scenario is this:
I take end of each month a montly freeze of a set of data with last day of the month as the effective date and as a field Effective date to a table (fact_table). So thousands of rows which are linked to last day of the repective month.
I've created date table to my model using code:
Solved! Go to Solution.
The problem is that the DATEADD is returnin 28 November, which has no data. Try
Reported value 3MO Ago =
VAR CurrentDate =
LOOKUPVALUE ( 'Date'[Date], 'Date'[Is Last Effective Date], 1 )
RETURN
CALCULATE (
[Reported value],
TREATAS ( { EOMONTH ( CurrentDate, -3 ) }, 'Date'[Date] )
)
What do you get if you go into the data view and filter the date table for Is Last Effective Date = 1 ?
28.2.2023 and related field values to it.
The problem is that the DATEADD is returnin 28 November, which has no data. Try
Reported value 3MO Ago =
VAR CurrentDate =
LOOKUPVALUE ( 'Date'[Date], 'Date'[Is Last Effective Date], 1 )
RETURN
CALCULATE (
[Reported value],
TREATAS ( { EOMONTH ( CurrentDate, -3 ) }, 'Date'[Date] )
)
This solves my problem now but I will face it again in the future when number of days is not 28.
In my case best solution would probably be that instead Last Effective date = 1 returns 28.2.2023 it should return 1 to all dates in this last month (and always 1 for all days in the last reporting month). I have values only for one day for each month thus I can select all the days without numbers changing.
The code I posted should work for any month, it will get the last day of the month 3 months ago regardless of the number of days in any month.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |