Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PBI5851
Helper V
Helper V

Calculate average active length

Hello,

I have a table that captures for every day each and every product that is active. 

Ex: 

Date ProductID

DateProductID
1/1/2020PID234
1/1/2020PID444
1/1/2020PID657
1/2/2020PID234
1/2/2020PID444
1/3/2020PID444
1/3/2020PID234
1/3/2020PID657
1/4/2020PID657
1/5/2020PID234

 

So when i have to provide how many Products were active for a given day, i do a count of ProductID for a specific day. Using above table, PID657 was active on 1st, 3rd and 4th, so products can go in and out. But the request is to capture what is the average that a Product has been active. I'm not sure on how exactly I can achieve that. Any help please. 

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@PBI5851 

 

not very clear about your request. Could you please share the expected output for your sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@PBI5851 

please try this

average = 
COUNTROWS('dateproductid')/DISTINCTCOUNT(dateproductid[ProductID])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
ryan_mayu
Super User
Super User

@PBI5851 

 

not very clear about your request. Could you please share the expected output for your sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Not very strong on my math skills 🙂 . But basically what i intend to capture is, within the date period of the date slicer that i have for the visual, how many months has each Product been on the table, divide by the total number of products within that date range as per the slicer. 

Hi @PBI5851 ,

 

It 's still not clear for me. Would you please tell us what your expected output based on the sample data?

 

Best Regards,

Dedmon Dai

Hi,

 So using the mentioned time and under the assumption that the time slicer has been selected for 1/1/20 - 1/3/20 the calculation would be.. 

PID234 was active for 3 days

PID444 was active for 3 days

PID657 was active for 2 days

So the average active life length for that time period is 8 (total days each product was active) / 3 (total number of products within that time). So, the final value to be displayed in 2.6 days.

 

Hope this helps.

@PBI5851 

please try this

average = 
COUNTROWS('dateproductid')/DISTINCTCOUNT(dateproductid[ProductID])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I do something very similar with inventory, I would assume it should work the same.  Basically I want to take the average inventory of each day.

 

So I do

AVERAGEX( VALUES ( Dates[Date]), [count you want to average] )

This will average it over the relevant filter datte range

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.