Forum Discussion
Iterating over columns , or "filtering rows" using DAX
2 Replies
- lbendlin
Super User
I'm trying to reproduce some operations which I know how to do in Python.That's called "fighting the API". Don't do that. Embrace Power BI for what it is, and use other tools if Power BI is not suitable.
Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - LucieKFrequent Visitor
Thanks Ibendlin for your reply. I can try to reduce my question to the issue of filtering tables "horizontally" instead of "vertically" : is it possible using DAX without transposing, and without unpivoting?
The sample data above are typed (not a screenshot).
I know how to filter "vertically", ie for a particular column, keep only rows where the value in the particular column matches a condition. Say I want to filter the sample matrix I have given above so that I only keep rows where the value in column A is >=0.5:mynewtable = FILTER('thematrixabove', 'thematrixabove'[A] >=0.5)will yieldA B C DA 1 0.3 0.8 0.7B 0.5 1 0.2 0.1D 0.7 0.6 0.2 1Is this possible "horizontally", ie keep only columns where the value in a particular ROW matches a condition, without transposing the table first?Something likemynewtable = FILTER('thematrixabove', 'thematrixabove'.rowlabel[A] >=0.5)to yieldA C DA 1 0.8 0.7B 0.5 0.2 0.1C 0.2 1 0.9D 0.7 0.2 1I suspect it's not possible; I've searched and haven't found anything so I guess the only option is to keep transposing back and forth? I later realized I could also unpivot it but that's also a messy workaround, I'd like to know if there is a "native" way of iterating over columns.