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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors