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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
KatBous
Frequent Visitor

Average total calculated by weekly date

Hi to all and many thanks in advance!

I have this information. 

I produce a weekly report. I want to calculate by the date of each report a) how many positions were still open by each report date, b) how many positions had closed by by each report date, c) what the average time to recruit (for all positions) was by each report date.

I do not know if it plays a role, but the report is every Thursday.

 

Position TitleDate position openedDate position closedTime to recruit
a01/01/202220/01/202219
b15/01/202230/01/202215
c16/01/202218/01/20222
d14/03/202216/03/20222
e20/03/202205/05/202245
f25/03/202225/4/202230
g25/4/202201/5/20227
1 ACCEPTED SOLUTION

Hi, @KatBous 

 

You can try the following methods.
Measure:

Count open =
VAR _N1 =
    CALCULATE (
        COUNT ( 'Table'[Position Title] ),
        FILTER (
            ALL ( 'Table' ),
            [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
                && [Date position closed] >= SELECTEDVALUE ( 'Report date'[Date] )
                && [Date position closed] <> BLANK ()
        )
    )
VAR _N2 =
    CALCULATE (
        COUNT ( 'Table'[Position Title] ),
        FILTER (
            ALL ( 'Table' ),
            [Date position closed] = BLANK ()
                && [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
        )
    )
RETURN
    _N1 + _N2
Count closed = 
CALCULATE (
    COUNT ( 'Table'[Position Title] ),
    FILTER (
        ALL ( 'Table' ),
        [Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] )
            && [Date position closed] <> BLANK ()
    )
)

vzhangti_0-1669108986169.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

4 REPLIES 4
KatBous
Frequent Visitor

Yes, it works great! Thank you @v-zhangti !

v-zhangti
Community Support
Community Support

Hi, @KatBous 

 

You can try the following methods.

Create a new date table and calculate Thursday.

Date = CALENDAR(MIN('Table'[Date position opened]),MAX('Table'[Date position closed]))

Column:

Weekday = WEEKDAY([Date],2)

Extract the date of each report.

New table:

Report date = FILTER('Date',[Weekday]=4)

vzhangti_0-1668738334245.png

Measure:

Count open =
CALCULATE (
    COUNT ( 'Table'[Position Title] ),
    FILTER (
        ALL ( 'Table' ),
        [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
            && [Date position closed] >= SELECTEDVALUE ( 'Report date'[Date] )
    )
)
Count closed =
CALCULATE (
    COUNT ( 'Table'[Position Title] ),
    FILTER (
        ALL ( 'Table' ),
        [Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] )
    )
)
Average =
CALCULATE (
    AVERAGE ( 'Table'[Time to recruit] ),
    FILTER (
        ALL ( 'Table' ),
        [Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] )
    )
)

vzhangti_1-1668738524400.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Thank you so much @v-zhangti  for the immediate and detailed reply!!!

 

One info that I forgot to include in my example table (new one below) is that some rows have blank "Date position closed" and "Time to recruit", as some positions are still open when I draft the report. How should I change the measures?

 

And also, using the measures, the table in PowerBi stops one week before the last week. It stops in 10 November while the last report date is 17 November.

Position TitleDate position openedDate position closedTime to recruit
a18/10/202219/10/20222,00
b18/10/202201/11/202215,00
c20/10/2022  
d25/10/2022  
e25/10/2022  
f25/10/2022  
g25/10/2022  
h04/11/202214/11/202211,00
i08/11/2022  

Hi, @KatBous 

 

You can try the following methods.
Measure:

Count open =
VAR _N1 =
    CALCULATE (
        COUNT ( 'Table'[Position Title] ),
        FILTER (
            ALL ( 'Table' ),
            [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
                && [Date position closed] >= SELECTEDVALUE ( 'Report date'[Date] )
                && [Date position closed] <> BLANK ()
        )
    )
VAR _N2 =
    CALCULATE (
        COUNT ( 'Table'[Position Title] ),
        FILTER (
            ALL ( 'Table' ),
            [Date position closed] = BLANK ()
                && [Date position opened] <= SELECTEDVALUE ( 'Report date'[Date] )
        )
    )
RETURN
    _N1 + _N2
Count closed = 
CALCULATE (
    COUNT ( 'Table'[Position Title] ),
    FILTER (
        ALL ( 'Table' ),
        [Date position closed] <= SELECTEDVALUE ( 'Report date'[Date] )
            && [Date position closed] <> BLANK ()
    )
)

vzhangti_0-1669108986169.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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