cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tasmiaa Regular Visitor
Regular Visitor

DAX - How to flag with multiple conditions

I have a table as defined below. The DAX column is the column I am trying to create.

 

I want to have the DAX column flag each row with a yes or no. 

 

Conditions for a yes

  • Person was at a location on Oct 1, 2018 (last day of the quarter)
  • Person was at the same location any other date previous in 2018

 

Condition for no

  • Person was at a different location on Oct 1, 2018 than the location specified on the date (ex: Jane was at location B on Oct 1, and therefore gets flagged yes on location B but not A for every other date)
  • Person was not any any location on Oct 1, 2018 (ex: Mike has only 1 date that is not Oct 1).

 

How would I write the DAX for this flag? I've tried to think of a way to do it with a nested IF but I can't seem to figure it out. Thanks. 

 

NameDateLocationDAX COLUMN
BobMonday, October 1, 2018Ayes
BobMonday, January 1, 2018Ayes
BobThursday, March 1, 2018Ayes
JaneMonday, January 1, 2018Ano
JaneThursday, March 1, 2018Byes
JaneMonday, October 1, 2018Byes
MikeMonday, January 1, 2018Bno
JerryMonday, October 1, 2018Cyes
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: DAX - How to flag with multiple conditions

Hi @tasmiaa

Try this for your column. It assumes that no rows have a blank() at Location:

 

 

DAXColumn =
VAR _OctoberLocation =
    LOOKUPVALUE (
        Table1[Location],
        Table1[Date], DATE ( 2018, 10, 1 ),
        Table1[Name], Table1[Name]
    )
RETURN
    IF ( Table1[Location] = _OctoberLocation, "Yes", "No" )

 

Code formatted with   www.daxformatter.com

 

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: DAX - How to flag with multiple conditions

Hi @tasmiaa

Try this for your column. It assumes that no rows have a blank() at Location:

 

 

DAXColumn =
VAR _OctoberLocation =
    LOOKUPVALUE (
        Table1[Location],
        Table1[Date], DATE ( 2018, 10, 1 ),
        Table1[Name], Table1[Name]
    )
RETURN
    IF ( Table1[Location] = _OctoberLocation, "Yes", "No" )

 

Code formatted with   www.daxformatter.com

 

View solution in original post

tasmiaa Regular Visitor
Regular Visitor

Re: DAX - How to flag with multiple conditions

Thank you! That worked wonderfully! I didn't even know I could make a var. 

Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors