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.
Hi I am trying to interatively count rows in PowerBI that meet a given condition. If the values began in cell A2 in Excel, the equation starting in B2 would be: =countif($a$2:a2,a2)... How would I do this in DAX or M? Thank you for any help any one can provide!
Row Column A Column B
2 a 1
3 a 2
4 a 3
5 b 1
6 b 2
7 b 3
Solved! Go to Solution.
@10119166 here is the dax , change column name and table name as per your data model
My Count = VAR __r = MAX( Table[Row] ) RETURN CALCULATE( COUNTROWS( Table ), ALLEXCEPT( Table, Table[Column A] ), Table[Row] <= __r )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you so much for your help! This worked great!
You can use the following for a new calculated column:
Calculated Column = var __CurrentRow = 'Table'[Row] var __CurrentColumns = 'Table'[Column] return CALCULATE( COUNTROWS('Table'), FILTER( 'Table', 'Table'[Column] = __CurrentColumns && 'Table'[Row] <= __CurrentRow ) )
or the following as a measure
Measure = CALCULATE( COUNTROWS('Table'), FILTER( ALL( 'Table'), MAX( 'Table'[Row] ) >= 'Table'[Row] ), VALUES( 'Table'[Column]) )
@10119166 here is the dax , change column name and table name as per your data model
My Count = VAR __r = MAX( Table[Row] ) RETURN CALCULATE( COUNTROWS( Table ), ALLEXCEPT( Table, Table[Column A] ), Table[Row] <= __r )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
94 | |
82 | |
70 | |
64 |
User | Count |
---|---|
116 | |
106 | |
94 | |
79 | |
72 |