Forum Discussion
DAX Query
- 4 years ago
Hi Anonymous ,
You are right, that this is not as trivial as in Excel. Normally you would need to do some unpivoting on your table to get your result as explained here:
Solved: Power Query - count across columns if condition me... - Microsoft Power BI Community
However, a quick and dirty solution could be something like this:
Here the code:
TomsNewCountColumn = IF ( 'Table12'[A] = TRUE, 1, 0) + IF ( 'Table12'[B] = TRUE, 1, 0) + IF ( 'Table12'[C] = TRUE, 1, 0) + IF ( 'Table12'[D] = TRUE, 1, 0) + IF ( 'Table12'[E] = TRUE, 1, 0)
Be aware though that this is not scalable and I would always go for some proper changes on your table before applying the code above. However, since your query was to count all trues accross columns, it might still work for you ๐
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Hi Anonymous ,
You are right, that this is not as trivial as in Excel. Normally you would need to do some unpivoting on your table to get your result as explained here:
Solved: Power Query - count across columns if condition me... - Microsoft Power BI Community
However, a quick and dirty solution could be something like this:
Here the code:
TomsNewCountColumn = IF ( 'Table12'[A] = TRUE, 1, 0) + IF ( 'Table12'[B] = TRUE, 1, 0) + IF ( 'Table12'[C] = TRUE, 1, 0) + IF ( 'Table12'[D] = TRUE, 1, 0) + IF ( 'Table12'[E] = TRUE, 1, 0)
Be aware though that this is not scalable and I would always go for some proper changes on your table before applying the code above. However, since your query was to count all trues accross columns, it might still work for you ๐
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/