top of page
Search

How to Display the Number of Rows in a Power BI Table Visual?

  • Writer: aleksvp
    aleksvp
  • Sep 13
  • 1 min read
ree

Power BI, despite being a powerful tool, can have some frustrating limitations. A common example is the inability to directly display the total number of rows within a table visual.


Well, here is a solution: use a Python Visual.


Add it to your report with the same fields of your visual table. It wil work even with field parameters.


Then, use the the following script:

import matplotlib.pyplot as plt

num_linhas = len(dataset)
format_numer = f"{num_linhas:,}".replace(",", ".")

plt.figure(figsize=(10,2))
plt.text(0.5, 0.5, rotulo,
         fontname="Segoe UI",
         fontsize=60, color='#666666', ha='center', va='center')
plt.axis('off')
plt.gca().set_facecolor("none")   
plt.gcf().patch.set_alpha(0.0) 
plt.show()

It is a very simple script, the key part is "len(dataset)", the rest is just format stuff.


There’s a catch: you can’t use Python visuals in public reports. If you want to keep that information just for logged-in users, one workaround is to hide the visual with bookmarks and add a button to show it. You can control the button’s fill color so it only shows up when a user is logged in; otherwise, it stays hidden. It’s not a perfect fix — someone could still find the button — but it does the job. If the Python visual isn’t hidden, the report will throw an error.


 
 
 

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2020 by Basic Dev. Proudly created with Wix.com

bottom of page