Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Anyone have a clue how I can calculate the following DAX equation for the same period last year?
Solved! Go to Solution.
Hi @kajelliott ,
I am not sure how your semantic model looks like, please try the following code as shown below.
Previous Est Value =
CALCULATE (
SUMX (
FILTER (
'table',
'table'[Created On] <= MAX ( 'Calendar'[Date] )
&& (
ISBLANK ( 'table'[Close Date] )
|| 'table'[Close Date] > MAX ( 'Calendar'[Date] )
)
),
( 'table'[Est. Revenue] )
),
CROSSFILTER ( 'table'[Created On], 'Calendar'[Date], NONE ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
If I've misunderstood you, please provide detailed sample data and the results you are hoping for. We can better understand the problem and help you. Show it as a screenshot or excel. Please remove any sensitive data in advance.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @kajelliott ,
I am not sure how your semantic model looks like, please try the following code as shown below.
Previous Est Value =
CALCULATE (
SUMX (
FILTER (
'table',
'table'[Created On] <= MAX ( 'Calendar'[Date] )
&& (
ISBLANK ( 'table'[Close Date] )
|| 'table'[Close Date] > MAX ( 'Calendar'[Date] )
)
),
( 'table'[Est. Revenue] )
),
CROSSFILTER ( 'table'[Created On], 'Calendar'[Date], NONE ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
If I've misunderstood you, please provide detailed sample data and the results you are hoping for. We can better understand the problem and help you. Show it as a screenshot or excel. Please remove any sensitive data in advance.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I believe this worked, thank you!
@kajelliott you can use the SAMEPERIODLASTYEAR function. Modify your DAX formula as follows:
SamePeriodLastYear Est Value =
CALCULATE(
SUMX(
FILTER(
ALL('table'),
'table'[Created On]
>= SAMEPERIODLASTYEAR(MAX('Calendar'[Date]))
&& (ISBLANK('table'[Close Date]) || 'table'[Close Date] > SAMEPERIODLASTYEAR(MAX('Calendar'[Date])))
),
'table'[Est. Revenue]
),
CROSSFILTER('table'[Created On], 'Calendar'[Date], NONE)
)
@DallasBaba - thanks for your suggestion!
Coming up with an error around the calendar date when SAMEPERIODLASTYEAR is included in the expression.
Error states 'The first argument to 'SAMEPERIODLASTYEAR' must specify a column'
Any thoughts?
User | Count |
---|---|
16 | |
15 | |
14 | |
12 | |
11 |
User | Count |
---|---|
19 | |
15 | |
14 | |
11 | |
10 |