cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
masons21 Frequent Visitor
Frequent Visitor

Self-populating table

I'm looking to build a table that references a database. Basically, on the last day of each month I want to count the number of rows in the database and record it with the associated month. I'd like to generate a new row with this number each month. I can do this manually right now, but it would be great to do it automatically. Is this possible in Power BI Desktop? The database is connected via DirectQuery but importing it is an option if need be. 

4 REPLIES 4
Super User
Super User

Re: Self-populating table

Hi @masons21 

If all tables have a date stamp you can just use it as a group by in your visual and create a measure that does cont rows on each table.

COUNTROWS( table )
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

masons21 Frequent Visitor
Frequent Visitor

Re: Self-populating table

Thanks for your suggestion @Mariusz 

 

That's not exactly what I need to do - I can use the COUNTROWS function but I need the total number of rows in the database each month, regardless of when the rows were generated. So the dates associated with them are meaningless for this purpose as there may be carry-over each month. I need a new row to be generated in a new table each month that populates with the total number of rows in the database at that time.

Super User
Super User

Re: Self-populating table

Hi @masons21 

You can not insert rows in query editor ( to my knowledge ), if you are working with direct query ( sql I'm guessing ) you might as well do it there.

If no one is removing records from your tables ( should not happen anyway ), you could create a measure with running total like below.

 

Measure = 
COUNTROWS(
    FILTER(
        ALL( 'Table' ),
        'Table'[createdDate] <= MAX('Table'[createdDate] )
    )
)

This would return 

 


image.png
Based on dataset 

image.png

 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

 

Community Support Team
Community Support Team

Re: Self-populating table

hi, @masons21 

Power bi could only add column data, for your case, I think you could use the logic to create a measure or a calculate column for it.

 

Best Reards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)