Forum Discussion
o59393
Post Prodigy
5 years agoIF with measure
Hi all I am trying to create an if measure like this: IF(
HASONEVALUE(facilities[bottler])="ABI El Salvador",
CALCULATE(
[Complaints],
'date'[MM YYYY]=DATE(2020,11,1)...
- 5 years ago
Hi,
Try this measure
=
IF(SELECTEDVALUE(facilities[bottler])="ABI El Salvador",CALCULATE([Complaints],DATESBETWEEN('date'[date],date(year(min('date'[date]))-1,11,1),date(year(min('date'[date]))-1,12,31))),CALCULATE([Complaints],PREVIOUSYEAR('date'[date])))
o59393
Post Prodigy
5 years ago
I didn't. Let me give you an example:
Let's say the yellow cell is a date slicer. Since the date contains present year, the measure should calculate the previous year for november 2020 and december 2020 if "ABI El Salvador" is selected.
There must be something wrong in the red part of the DAX:
CC PY =
IF(
SELECTEDVALUE(facilities[bottler])="ABI El Salvador",
CALCULATE([Complaints],
DATESBETWEEN('date'[date],
edate(
min('date'[date]),-1),
max('date'[date]))),
CALCULATE([Complaints],
PREVIOUSYEAR('date'[date])
)
)
I attach the excel. https://1drv.ms/x/s!ApgeWwGTKtFdh0Qw3qTRuW4VTI8D?e=ZidRvL
Let me know if you have questions.
Thanks!
Ashish_Mathur
Super User
5 years agoHi,
Try this measure
=
IF(SELECTEDVALUE(facilities[bottler])="ABI El Salvador",CALCULATE([Complaints],
DATESBETWEEN('date'[date],date(year(min('date'[date]))-1,11,1),date(year(min('date'[date]))-1,12,31))),CALCULATE([Complaints],PREVIOUSYEAR('date'[date])))
- o593935 years ago
Post Prodigy
- Ashish_Mathur5 years ago
Super User
You are welcome.