Forum Discussion
How to add a Serial Row Number Column in Power BI Table / Matrix visual?
- 9 years ago
Hi ShmuelM,
Grabbing in your table just add a measure with the countrows:
Row_Number = CALCULATE ( COUNTROWS(Profit_Table), FILTER ( ALLSELECTED ( Profit_Table ), Profit_Table[Position] <= MAX ( Profit_Table[Position]) ) )As you can see in the print below it counts the number of rows no matter if you have slicer or not, left table is the full data, right table is influenced by slicer.
Please be aware that this measure is influenced by the order of your Position so if you want to order by another column this will give you the row number in a different order also.
Regards,
MFelix
Hi sbvsv ,
Thanks for answering ,
I saw this solution but this is not answering my question .
for example I have this this table, 2 columns :ID , CITY in the phisic table:
ID , CITY
1 WASHINGTON
2 AMSTERDAM
3 LONDON
4 ROMA
IF I will select and filter in the report only 3 cities : WASHINGTON , AMSTERDAM , ROMA
The Table In PowerBI will show me
1 WASHINGTON
2 AMSTERDAM
4 ROMA.
I want to see it like this:
1 WASHINGTON
2 AMSTERDAM
3 ROMA .
I don't want the 'ID' Of the row , just a running number in the display table in Power BI that will change every time I chage filter / order.
I hope the question is clearer.
Hi ShmuelM,
Grabbing in your table just add a measure with the countrows:
Row_Number =
CALCULATE (
COUNTROWS(Profit_Table),
FILTER ( ALLSELECTED ( Profit_Table ), Profit_Table[Position] <= MAX ( Profit_Table[Position]) )
)As you can see in the print below it counts the number of rows no matter if you have slicer or not, left table is the full data, right table is influenced by slicer.
Please be aware that this measure is influenced by the order of your Position so if you want to order by another column this will give you the row number in a different order also.
Regards,
MFelix
- hmedinaa9 years agoFrequent Visitor
Very helpfully
Thanks
- hmedinaa9 years agoFrequent Visitor
Very helpfully
Thanks
- Yi7 years agoRegular Visitor
I have a new challenge in this area. I have a table with Index, City, Street, Value1 and Value2. There are duplicated value in City and Street, but Value1 and Value2 are different. Like
Index City Street Value1 Value2
1 A 123 D1 C1
2 A 123 D2 C2
3 A 456 D3 C3
4 A 456 D4 C4
5 B 131 D5 C5
I use a scatter to see the Value distribution and I also want to use a table to see how many City and Street couples when I change a filter by Value1
I have the problem to show the row number in table, it show like
RowNo City Street
2 A 123
4 A 456
5 B 131
What I want is
RowNo City Street
1 A 123
2 A 456
3 B 131
- ajohn17 years agoAdvocate I
Microsoft should have just added a on/off for row numbers for tables and matrix. I'm needing help with this exact same question. Has this been answered for you?
- Garridex6 years agoRegular Visitor
Save my day! Thanks!
MFelix wrote:Hi ShmuelM,
Grabbing in your table just add a measure with the countrows:
Row_Number = CALCULATE ( COUNTROWS(Profit_Table), FILTER ( ALLSELECTED ( Profit_Table ), Profit_Table[Position] <= MAX ( Profit_Table[Position]) ) )As you can see in the print below it counts the number of rows no matter if you have slicer or not, left table is the full data, right table is influenced by slicer.
Please be aware that this measure is influenced by the order of your Position so if you want to order by another column this will give you the row number in a different order also.
Regards,
MFelix
Save my day! Thanks!
- LauraBueno6 years agoHelper III
Hi! I have a similar problem and just tried your formula and it is working fine for me as well! Thanks!
Just quick question, I would like to use the measure created in a graph, so that I plot my variable vs this counter we've created, but it is not working.
Any idea how to do this?
Thanks a lot in advance!
- LauraBueno6 years agoHelper III
Hi! I have a similar problem and just tried your formula and it is working fine for me as well! Thanks!
Just quick question, I would like to use the measure created in a graph, so that I plot my variable vs this counter we've created, but it is not working.
Any idea how to do this?
Thanks a lot in advance!
- Anonymous4 years agoNot applicable
This doesn't seem to work with a matrix...any clue as to why?
- MFelix4 years agoSuper User
Hi Anonymous ,
This depends on the context can you share some mockup data?
- Anonymous4 years agoNot applicable
Sure!
So I have the following Matrix:I need to add one row, at the beggining of the matrix, with the row number: 1,2,3,4,5,6 .....
I have tried it your way and it just gives random numbers that i can't include in the matri. The closest I have been to achieving my goal was this expression:Row_Number =RANKX(ALL(v_inf_ttv_alertas_campanas_dia[ds_campania]),[Sumatorio])However, I can only add the column as a value, wich obviously doesn't do what I want.
- marksn3 years agoFrequent Visitor
What about if you have a table visual comprising of columns from multiple table?
- MFelix3 years agoSuper User
Hi marksn ,
In this case you need to make your based on a virtual table created on that specif calculation, that is based on your selections.
- marksn3 years agoFrequent Visitor
Hi Miguel,
Thanks for the response. Do you know of an easy way to create a virtual table based on a table visual with multiple table & measure as source of columns? I reckon it can be done by copying the Performance Analyzer Query?