- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

IF 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),'date'[MM YYYY]=DATE(2020,12,1)),
CALCULATE([Complaints],
PREVIOUSYEAR('date'[date]))
)
I am using hasonvalue, followed by the column "bottler" equals to ABI El Salvador.
The measure seems to work, but the visual is:
Any idea how to get it right?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Try this measure
=
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@o59393 Hey ,
Use this one
IF(
SELECTEDVALUE(facilities[bottler])="ABI El Salvador",
CALCULATE(
[Complaints],
'date'[MM YYYY]=DATE(2020,11,1),'date'[MM YYYY]=DATE(2020,12,1)),
CALCULATE([Complaints],
PREVIOUSYEAR('date'[date]))
Try this and let me know .
or try this .
Calculate(calculate([Complaints],sameperiodlastyear(date[date]) , facilities[bottler])="ABI El Salvador" )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

hi @HarishKM
In fact I had tried that one. But returns a blank only.
I guess it should be solved by some kind of time intelligence formula.
THanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Try using the SELECTEDVALUE function instead of HASONEVALUE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @d_gosbell
It worked however it shows blank and it shouldn't 😞
Do you if it's possible to tell the time intelligence function "previous year" to calculate only the last 2 months?
In this case, calculate the previous year's last 2 months (november 2020 and december 2020)
The dax is below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Does this measure work?
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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:
I attach the excel. https://1drv.ms/x/s!ApgeWwGTKtFdh0Qw3qTRuW4VTI8D?e=ZidRvL
Let me know if you have questions.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Try this measure
=
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You are welcome.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
08-20-2024 09:13 AM | |||
06-18-2024 06:16 AM | |||
09-27-2024 05:56 AM | |||
09-27-2024 12:36 AM | |||
Anonymous
| 11-19-2023 06:21 PM |