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.
I want to create a measure that calculates the value of the "Objectif" measure of the previous period according to the date filter:
For example :
if filter on Year 2021 take the value of 2020
if filter on Qt4 2021 take the value of Qt 3 2021
if filter october 2021 take the value of september 2021
Automatically in dax?
Solved! Go to Solution.
Hi @forbi
yeah, here's an example,
Measure =
var _year= ISFILTERED('calendar'[Year])
var _quarter= ISFILTERED('calendar'[Quarter])
var _month = ISFILTERED('calendar'[Month])
return
SWITCH(TRUE(),
_year=TRUE() && _quarter= FALSE(), SELECTEDVALUE('calendar'[Year])-1&"",
_quarter=TRUE() && _month= FALSE(), SELECTEDVALUE('calendar'[Year]) &"-"& SELECTEDVALUE('calendar'[Quarter])-1,
_month=TRUE(),SELECTEDVALUE('calendar'[Year]) &"-"& SELECTEDVALUE('calendar'[Quarter])&"-"& SELECTEDVALUE('calendar'[Month])-1,
"please select")
sum of period =
VAR _year =
ISFILTERED ( 'calendar'[Year] )
VAR _quarter =
ISFILTERED ( 'calendar'[Quarter] )
VAR _month =
ISFILTERED ( 'calendar'[Month] )
RETURN
SWITCH (
TRUE (),
_year = TRUE ()
&& _quarter = FALSE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Year] ) - 1
),
[value]
),
_quarter = TRUE ()
&& _month = FALSE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = SELECTEDVALUE ( 'calendar'[Year] )
&& QUARTER ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Quarter] ) - 1
),
[value]
),
_month = TRUE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = SELECTEDVALUE ( 'calendar'[Year] )
&& MONTH ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Month] ) - 1
),
[value]
),
"please select"
)
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @forbi
yeah, here's an example,
Measure =
var _year= ISFILTERED('calendar'[Year])
var _quarter= ISFILTERED('calendar'[Quarter])
var _month = ISFILTERED('calendar'[Month])
return
SWITCH(TRUE(),
_year=TRUE() && _quarter= FALSE(), SELECTEDVALUE('calendar'[Year])-1&"",
_quarter=TRUE() && _month= FALSE(), SELECTEDVALUE('calendar'[Year]) &"-"& SELECTEDVALUE('calendar'[Quarter])-1,
_month=TRUE(),SELECTEDVALUE('calendar'[Year]) &"-"& SELECTEDVALUE('calendar'[Quarter])&"-"& SELECTEDVALUE('calendar'[Month])-1,
"please select")
sum of period =
VAR _year =
ISFILTERED ( 'calendar'[Year] )
VAR _quarter =
ISFILTERED ( 'calendar'[Quarter] )
VAR _month =
ISFILTERED ( 'calendar'[Month] )
RETURN
SWITCH (
TRUE (),
_year = TRUE ()
&& _quarter = FALSE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Year] ) - 1
),
[value]
),
_quarter = TRUE ()
&& _month = FALSE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = SELECTEDVALUE ( 'calendar'[Year] )
&& QUARTER ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Quarter] ) - 1
),
[value]
),
_month = TRUE (),
SUMX (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = SELECTEDVALUE ( 'calendar'[Year] )
&& MONTH ( 'Table'[Date] )
= SELECTEDVALUE ( 'calendar'[Month] ) - 1
),
[value]
),
"please select"
)
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
107 | |
93 | |
77 | |
65 | |
53 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |