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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Custom column: IF equals to one of multiple value

Hi,

 

As the title indicate, I am looking for solutions for creating a custom column using an IF statement based on whether the value of that column matches any values in the providing list.
In SQL, the query is something like:

 

SELECT count( case when column_a in (101, 133, 150, 168, 199, 323, 456, 888, 999) then 1 else 0)

 

The screenshot is a simplified approach to describe my question. Please advise how to approach this goal in adding custom column windows. Thank you in advance!

 

custom column.PNG

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Try usinig List.Contains like this instead.

 

= if List.Contains({30,40,50}, [age]) then 1 else 0

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

@mahoneypat gave a good M version of this.

 

If you happen to want to do this DAX instead, it would look like this:

IF ( [age] IN { 30, 40, 50 }, 1, 0 )

 

mahoneypat
Employee
Employee

Try usinig List.Contains like this instead.

 

= if List.Contains({30,40,50}, [age]) then 1 else 0

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.