Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am trying get previous month figures, but it the DAX i have does not show the correct figure.
I have 3 measures:
Measure1 (correct):
-----------
Measure2 (correct):
-----------
Measure3 (incorrect):
This measure shows the value of measure [Total List Price] instead [Testing WA Price Monthly]
-----------
Solved! Go to Solution.
Hi @Anonymous
Please try this Measure.
Testing WA Price Monthly Prev =
VAR max_date =
MAX ( 'Posting date'[Date] )
VAR max_month =
MONTH ( max_date )
VAR max_year =
YEAR ( max_date )
VAR year =
IF ( max_month = 1, max_year - 1, max_year )
VAR month =
IF ( max_month = 1, 12, max_month - 1 )
VAR res =
CALCULATE (
[Testing WA Price Monthly],
FILTER (
ALL ( 'Posting date' ),
YEAR ( 'Posting date'[Date] ) = year
&& MONTH ( 'Posting date'[Date] ) = month
)
)
RETURN
res
The result looks like this:
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Please try this Measure.
Testing WA Price Monthly Prev =
VAR max_date =
MAX ( 'Posting date'[Date] )
VAR max_month =
MONTH ( max_date )
VAR max_year =
YEAR ( max_date )
VAR year =
IF ( max_month = 1, max_year - 1, max_year )
VAR month =
IF ( max_month = 1, 12, max_month - 1 )
VAR res =
CALCULATE (
[Testing WA Price Monthly],
FILTER (
ALL ( 'Posting date' ),
YEAR ( 'Posting date'[Date] ) = year
&& MONTH ( 'Posting date'[Date] ) = month
)
)
RETURN
res
The result looks like this:
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
this is what I want:
@Anonymous , Try with date table , marked as date table , and use month from date table in visual
Testing WA Price Monthly Prev =
CALCULATE([Testing WA Price Monthly]
, dateadd( 'Date'[Date], -1,MONTH))
Also refer why TI failes - https://www.youtube.com/watch?v=OBf0rjpp5Hw
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
I just check the tabular model, 'Posting Date' is marked as date table.
Thanks @amitchandak , the table 'Posting Date' I am using is a date table and I am using the month form 'Posting Date' table. I am not sure what do you mean by "marked as a date table".
My data source is tabular model.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |