The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
To start with my calendar Dimention looks like this because we have a slicer which limits to current month
Solved! Go to Solution.
Hello @Anonymous
The date table generated from your code in Dates_Dim runs from 12/1/2018 - 10/31/2019. Using time intelligence functions with a date table that does not cover the full years can give you wrong answers. Try changing your Dates_Dim code to the following.
Dates_Dim = ADDCOLUMNS( CALENDAR ( DATE ( YEAR ( TODAY() ) - 1, 1, 1 ), DATE ( YEAR ( TODAY() ), 12, 31 ) ), "Day", DAY ( [Date] ), "Month", MONTH ( [Date] ), "Month_name", FORMAT ( [Date], "MMM" ), "Year", YEAR ( [Date] ) )
Is PYTD Measure not working of variance is not working.
1. Hope date table is marked as a date table in the model view.
2. Dates are continuous. In case dates are not continuous(means some dates are missing) SAMEPERIODLASTYEAR might not work properly
3. Create a formula like below and check are you getting correct values
On the Fly YTD LYTD Change % = Var _last_year= (maxx('Date',ENDOFYEAR(DATEADD('Date'[Date Filer],-12,MONTH)))) Var _This_year=(maxx('Date','Date'[Date Filer])) Var _min_last_year= (MINX('Date',STARTOFYEAR(DATEADD('Date'[Date Filer],-12,MONTH)))) Var _min_This_year=(Minx('Date',STARTOFYEAR('Date'[Date Filer]))) Var _last_year_val= CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_last_year && (Sales[Sales Date]) >=_min_last_year) Var _This_year_val =CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_This_year && (Sales[Sales Date]) >=_min_This_year) return (_This_year_val-_last_year_val)/_last_year_val*100Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
This solution did not work. Can someone provide me Dax how we could achieve this?
Hello @Anonymous
The date table generated from your code in Dates_Dim runs from 12/1/2018 - 10/31/2019. Using time intelligence functions with a date table that does not cover the full years can give you wrong answers. Try changing your Dates_Dim code to the following.
Dates_Dim = ADDCOLUMNS( CALENDAR ( DATE ( YEAR ( TODAY() ) - 1, 1, 1 ), DATE ( YEAR ( TODAY() ), 12, 31 ) ), "Day", DAY ( [Date] ), "Month", MONTH ( [Date] ), "Month_name", FORMAT ( [Date], "MMM" ), "Year", YEAR ( [Date] ) )
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
81 | |
57 | |
48 | |
48 |