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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

count number of days selected in filter

Hello!

 

I'm trying to create report in PowerBi that will show service uptime in percents. I have 2 tables: "Date" and "Notices" with information about services interruption in hours (column Duration). 

 

I created a mesure that gives me service uptime, but it's not working correctly if i chose two dates from the visual filter on report.

Measure = (CALCULATE(COUNTROWS('Date'),'Date'[Date])*24 - SUM(Notices[Duration]))/(CALCULATE(COUNTROWS('Date'),'Date'[Date])*24)
 
Could you please help me to create measure that will give correct uptime depending on dates selected in filter. 
I.e. if i chose range 10.05.2022 - 15.05.2022 with no notices about interruption in this dates it will return 100%. And so on.
 
Thanks!
 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

First, please make sure that there is one relationship created between Date and Notices tables base on Date fields. You can update the formula of Measure as below and check if it can get the correct result...

Measure =
VAR _fhours =
    COUNTROWS (
        FILTER (
            'Date',
            'Date'[Date] >= MIN ( 'Date'[Date] )
                && 'Date'[Date] <= MAX ( 'Date'[Date] )
        )
    ) * 24
RETURN
    DIVIDE ( _fhours - SUM ( Notices[Duration] ), _fhours )

If the above one can't help you get the desired result, please provide some sample data in your Notices table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

First, please make sure that there is one relationship created between Date and Notices tables base on Date fields. You can update the formula of Measure as below and check if it can get the correct result...

Measure =
VAR _fhours =
    COUNTROWS (
        FILTER (
            'Date',
            'Date'[Date] >= MIN ( 'Date'[Date] )
                && 'Date'[Date] <= MAX ( 'Date'[Date] )
        )
    ) * 24
RETURN
    DIVIDE ( _fhours - SUM ( Notices[Duration] ), _fhours )

If the above one can't help you get the desired result, please provide some sample data in your Notices table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Anonymous
Not applicable

Hi  @Anonymous , 

yes, your Measure did provide desired result. Thanks a lot!

But i also solved it by done this:

1) Created conditional column in table "Date" called "Boolean" that eaual 1 if Date column not empty.

2) Changed my measure from original post to this one:

Measure = (CALCULATE(COUNTROWS('Date'),'Date'[Boolean]=1)*24 - SUM(Notices['Duration']))/(CALCULATE(COUNTROWS('Date'),'Date'[Boolean]=1)*24) 

 

But anyway thanks again for the help!

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.