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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
vanessafvg
Super User
Super User

help with filter statement in DAX

i need to calculate a moving average over time, i need to get the no of employees at a point in time. 

 

i have a start date and i have an employee end date, how do i calculate the moving average over time, taking into consideration i am plotting on 2 different dates for the above?

 

currently i have this but it doesn't seem to work

No of Current Employees = CALCULATE(DISTINCTCOUNT('Employees All Time'[Employee No.]),
FILTER('Employees All Time',
min('Date'[Date]) >= 'Employees All Time'[Start Date]
&& MAX('Date'[Date]) < 'Employees All Time'[Leaving Date] )
)

 

 

this should give me a total at a day level.   

however i am also stuck as to how to calculate the average.

it doesn't return anything which is quite frustrasting help please 🙂

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




6 REPLIES 6
v-ljerr-msft
Employee
Employee

Hi @vanessafvg,

 

Could you try the formula below to see if it works in your scenario? Smiley Happy

 

No of Current Employees =
VAR currentDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Employees All Time'[Employee No.] ),
        FILTER (
            ALL ( 'Employees All Time' ),
            'Employees All Time'[Start Date] <= currentDate
                && 'Employees All Time'[Leaving Date] > currentDate
        )
    )

 

Regards

 thanks will give it a bash





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg,

 

Have you tried the solution? Does it work in your scenario? If it works, could you accept it as solution to close this thread? Smiley Happy

 

Regards

hi @v-ljerr-msft i have been working on something else, so can't say if its the solution yet sorry.  





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg,

 

That's OK. Just take your time. Smiley LOL

 

Regards

Woman LOL





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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