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
Anonymous
Not applicable

Calculate Moving average of Attrition

Hello All,

 

I am calculating moving average of attrition data which i have.

 

I have three tables.

 

1st Table:-- HeadCount Table which is having active people.

 

I have calculated the count as per my organization rule using below formula.

 

 

_Active HeadCount = CALCULATE (
    COUNT(HeadCount[Personnel Number]),
    FILTER (
        ALLEXCEPT(HeadCount,HeadCount[Gender],HeadCount[DU Description],HeadCount[Grade],HeadCount[SBU],HeadCount[Yearly Normalized Rating]),
		
        HeadCount[Date] <= SELECTEDVALUE ( ( HeadCount[Date]) )
    )
)

 

 

Here I have mentioned in Filter the column names which it should get filte in AllEXCEPT funtion, 

 

With this i am able to get Active headcount values as per the filteration.

 

2nd Table:- Release Data

 

In this table i have data regarding the people who released.

 

And i have calculated the count of release people using the below dax which is similar to above.

 

 

_Release Count = CALCULATE (
    COUNT('Release Data'[Personnel Number]),
    FILTER (
        ALLEXCEPT('Release Data','Release Data'[Attrition],'Release Data'[DU Description],'Release Data'[Gender],'Release Data'[Reason for release biz HR],'Release Data'[SBU],'Release Data'[Tenure Category],'Release Data'[Yearly Normalized Rating FY17]),
		
        'Release Data'[Date] <= SELECTEDVALUE ( ( 'Release Data'[Date])
    )
))

 

3rd Table:- Month Year Table

 

In my month year table i have column Date(MM/DD/YYYY format) which is having relation with Date column of above two tables.

 

Now the actual formula for moving average of attrition is

 

 

_Release Count/_Active_HeadCount

 

 

with this i got the average of attrition.

 

But when i included Gender Column from HeadCount table i got the output which is wrong as 

Capture.PNG

And when i included gender column from release data table im getting below values which are wrong.

 

Capture1.PNG

And then i have created a bridge table for Gender and created relation with both above tables of gender column.

 

Then when i included gender column from Gender table i got the output which is also wrong 

 

Capture2.PNG

 

Any help to solve this.

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

In this scenario, the formula below should work. Smiley Happy

_Release Count =
CALCULATE (
    COUNT ( 'Release Count'[Personnel Number] ),
    FILTER (
        ALL ( 'Month Year'[Date] ),
        'Month Year'[Date] <= MAX ( 'Month Year'[Date] )
            && 'Month Year'[Date] <= MAX ( 'Release Count'[Date] )
    )
)

 

Regards

View solution in original post

9 REPLIES 9
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

Based on my test with your shared pbix file, the formulas below should work in your scenario.

_Release Count = CALCULATE (
    COUNT('Release Count'[Personnel Number]),
    FILTER (
        ALL('Release Count'[Date]),
        'Release Count'[Date] <= SELECTEDVALUE ( ('Release Count'[Date]) )
    )
) 
_Sum of prv Headcount = CALCULATE (
    COUNT(HeadCount[Personnel Number]),
    FILTER (
        ALL(HeadCount[Date]),
        HeadCount[Date] <= SELECTEDVALUE ( ( HeadCount[Date]) )
    )
)

r1.PNG

 

 

Regards

Anonymous
Not applicable

@v-ljerr-msft Can you please give any suggestions...

 

Hi @Anonymous,

 

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

_Release Count = 
CALCULATE (
    COUNT('Release Count'[Personnel Number]),
    FILTER (
        ALL('Month Year'[Date]),
        'Month Year'[Date] <= MAX('Month Year'[Date] )
    )
) 

r3.PNG

 

Regards

Anonymous
Not applicable

@v-ljerr-msft thanks for the reply...

 

ya it is giving me the output as summing up the previous month values.

 

But if you observe the below image,

 

Capture.PNG

 

Its repeating the last value where actually theres no values exist from Dec-2017.

 

 

 

 

 

Hi @Anonymous,

 

In this scenario, the formula below should work. Smiley Happy

_Release Count =
CALCULATE (
    COUNT ( 'Release Count'[Personnel Number] ),
    FILTER (
        ALL ( 'Month Year'[Date] ),
        'Month Year'[Date] <= MAX ( 'Month Year'[Date] )
            && 'Month Year'[Date] <= MAX ( 'Release Count'[Date] )
    )
)

 

Regards

Anonymous
Not applicable

@v-ljerr-msft Thanks for the  help buddy...

 

But i dont see that, it is giving a moving average.

 

if you observe the below image

Capture.PNG

 

 

Here the Jan-17 Male value is not getting summedup with Feb-17 Male value.

 

I tried to use the ALLEXCEPT funtion as below

 

Capture1.PNG

 

 

But it is giving the error as

 

A single value for column 'Date' in table 'Release Data' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

Can you please help me with this..

 

 

v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

Could you share a sample pbix file(with just some sample/mock data) which can reproduce the issue, so that we can better assist on it? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. Smiley Happy

 

Regards

Anonymous
Not applicable

@v-ljerr-msft thanks for the reply 

 

 

I have sent you the datasheets and sample pbix file 

 

Please check once.

Anonymous
Not applicable

Can anyone please suggest me about this....

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.