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
YukiK
Impactful Individual
Impactful Individual

How to get a list of values from a column in DAX?

I'd like to get a list of values of a column in a table so that I can do a condition where " if (_myDepartment in _valuesOfColumn, do A, else B)". I'll use the boolean value from that variable in another variable.

 

I can use Values function, but I need to ignore the context filter so the list has the full list of values.

 

In short:

I currently have a variable where

VAR _listOfdistinctPrevUnits = { "E3", "L4", "F3", "B2", "B3", "L6" }
 
 

This essentially the values from a column of a table. I guess I wanna get these values dynamically.

 

I can't seem to find an answer for this, but any idea for how to accomplish this?

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

The VALUES function does this. Consider other similar functions too depending on your exact requirements: DISTINCT, ALL, ALLSELECTED).

 

View solution in original post

v-shex-msft
Community Support
Community Support

HI @YukiK,

You can try to use the following measure formula to compare selection and list of values to return tag:

Measure =
IF (
    COUNTROWS ( INTERSECT ( VALUES ( Table[Column] ), ALL ( Tableb[Column] ) ) ) > 0,
    "A",
    "B"
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @YukiK,

You can try to use the following measure formula to compare selection and list of values to return tag:

Measure =
IF (
    COUNTROWS ( INTERSECT ( VALUES ( Table[Column] ), ALL ( Tableb[Column] ) ) ) > 0,
    "A",
    "B"
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
AlexisOlson
Super User
Super User

The VALUES function does this. Consider other similar functions too depending on your exact requirements: DISTINCT, ALL, ALLSELECTED).

 

amitchandak
Super User
Super User

@YukiK , assume you want to use in a filter

 

filter(Table, _myDepartment in values(Table[Column]))

 

or

 

filter(Table, _myDepartment in allselected(Table[Column]))

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.