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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
stevedep
Memorable Member
Memorable Member

select values from list based on bolean array / list

Hi,

 

I am trying to select values from a list where my bolean (true/false) list would indicate to select the column. 

 

Something like. 

 

List.Select(datalist, listwithtruefalsevalues)

 

Quite common in R and other languages, you select rows from you dataframe based on an array of true/false values. 

 

Hope its clear.

 

Kind regards, Steve. 

 

@edhans , @ImkeF 

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@stevedep 

 

See if this help

let
    DataList= {1,2,3,4,5},
   Listwithtruefalse = {true,false,true,true,false},
Mergedlist=List.Zip({DataList,Listwithtruefalse }),

  Desiredlist = List.Transform(
List.Select(Mergedlist, (d)=>d{1}=true),(d)=>d{0})
in
    Desiredlist

View solution in original post

@stevedep @Zubair_Muhammad 

since you have 2 lists of the same lengths, why not use subscript to pick up responding values like this,

 

let
    DataList= {1,2,3,4,5},
    Listwithtruefalse = {true,false,true,true,false},
    Desiredlist = List.Accumulate({0..List.Count(Listwithtruefalse)-1}, {}, (s,c)=>if Listwithtruefalse{c} then s&{DataList{c}} else s)
in
    Desiredlist

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@stevedep 

 

See if this help

let
    DataList= {1,2,3,4,5},
   Listwithtruefalse = {true,false,true,true,false},
Mergedlist=List.Zip({DataList,Listwithtruefalse }),

  Desiredlist = List.Transform(
List.Select(Mergedlist, (d)=>d{1}=true),(d)=>d{0})
in
    Desiredlist

Thanks, I found a way to do it, turns out, it's the same approach as you suggest. So it probably makes sense 😃

@stevedep @Zubair_Muhammad 

since you have 2 lists of the same lengths, why not use subscript to pick up responding values like this,

 

let
    DataList= {1,2,3,4,5},
    Listwithtruefalse = {true,false,true,true,false},
    Desiredlist = List.Accumulate({0..List.Count(Listwithtruefalse)-1}, {}, (s,c)=>if Listwithtruefalse{c} then s&{DataList{c}} else s)
in
    Desiredlist

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.