Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

DAX Nested IF & AND

Hi,

 

I've got a formule now which im sure that could be so much better.

 

The formule is. 

 

Lorem Ipsum =
IF(AND(SessionDetails[ReferredById]=75665,SessionDetails[User1Id]=1),1,
(IF(AND(SessionDetails[ReferredById]=75665,SessionDetails[User1Id]=2),1,
IF(AND(SessionDetails[ReferredById]=75665,SessionDetails[User1Id]=3),1,
(IF(AND(SessionDetails[ReferredById]=75665,SessionDetails[User1Id]=4),1,0))))

 

I want all the UsersId1 to give back a 1 if the column ReferredByID = 75665, 

So IF(referredbyid = 75665 && userid = 1, or = 2, or = 3, or = 4,) 1 , 0

 

But i think this could be made so much easier and cleaner, my powerbi has trouble using it. 

 

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,
 
Lorem Ipsum =
SWITCH(
        TRUE(),
        SessionDetails[ReferredById]<>75665, 0,
        SessionDetails[User1Id] IN {1,2,3,4}, 1,
        0
)
 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous,
 
Lorem Ipsum =
SWITCH(
        TRUE(),
        SessionDetails[ReferredById]<>75665, 0,
        SessionDetails[User1Id] IN {1,2,3,4}, 1,
        0
)
 
Anonymous
Not applicable

You could try this- Create a new column as follows

 

Formula = if(Table[Referred by] = 75665 && Table[User id]=1, 1, 0)

 

I got this output:

 

IF AND DAX.png

 

 

Anonymous
Not applicable

mm i dont think i was clear enough. 

 

I want all the UsersId1 to give back a 1 if the column ReferredByID = 75665,

 

So IF(referredbyid = 75665 && userid = 1, or = 2, or = 3, or = 4,) 1 , 0

 

Something like that

Claster
Advocate II
Advocate II

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors