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

Wrong SUM for total

Hi I am using the following code for a measure to calculate the Full time equivalence. 

 

 

FTE = SUMX (
    VALUES ( 'Calendar'[Month] ),
    CALCULATE (
         SUM(Payroll[FTE])/100,
             FILTER (
                Payroll,
                ( Payroll[Payroll nb] <> 376 )
                    && ( Payroll[Payroll nb] <> 377 )
                    && ( Payroll[Payroll nb] <> 445 ) //exclude 3 specifics employees Expat
                    && 'Payroll'[Most Recent Hire Date] <= MAX ( Calendar[Date] )
                    && (
                        ISBLANK ( 'Payroll'[Administrative End Date] )
                            || 'Payroll'[Administrative End Date] >= MAX ( Calendar[Date] )
                    )
            )
        )
    )

 

When i show figures split by month in a table, the figure for each month is correct, but the total is wrong. 

 

MonthHeadcountFTE
jan505499.29
fev505498.46
mar498491.46
abr519512.32
mai515508.27
jun516508.51
jul521513.51
ago534526.51
set559551.07
out555547.07
nov568560.07
dez565557.55
TOTAL 636070049.71

 

What id like to have as TOTAL for FTE is 6274.09 

 

Any thoughts what is going worng or any thoughts about amends that ican do to make it work properly? 

 

Example FTE worksheet

2 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Based on my test, to create two measures separately should work well.

 

sum_nEW = CALCULATE (
        SUM('Payroll'[FTE])/100,
             FILTER (
                Payroll,
                ( Payroll[Payroll nb] <> 376 )
                    && ( Payroll[Payroll nb] <> 377 )
                    && ( Payroll[Payroll nb] <> 445 ) //exclude 3 specifics employees Expat
                    && 'Payroll'[Most Recent Hire Date] <= MAX ( Calendar[Date] )
                    && (
                        ISBLANK ( 'Payroll'[Administrative End Date] )
                            || 'Payroll'[Administrative End Date] >= MAX ( Calendar[Date] )
                    )))
FTE _NEW = SUMX(VALUES('Calendar'[Month]),[sum_nEW])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

@Anonymous

 

Use another calculate after the calculate function that you aleardy have and this will do the trick:

 

FTE = SUMX (
    VALUES ( 'Calendar'[Month] ),
    CALCULATE (
         CALCULATE(SUM(Payroll[FTE]))/100,
             FILTER (
                Payroll,
                ( Payroll[Payroll nb] <> 376 )
                    && ( Payroll[Payroll nb] <> 377 )
                    && ( Payroll[Payroll nb] <> 445 ) //exclude 3 specifics employees Expat
                    && 'Payroll'[Most Recent Hire Date] <= MAX ( Calendar[Date] )
                    && (
                        ISBLANK ( 'Payroll'[Administrative End Date] )
                            || 'Payroll'[Administrative End Date] >= MAX ( Calendar[Date] )
                    )
            )
        )
    )

View solution in original post

9 REPLIES 9
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Based on my test, to create two measures separately should work well.

 

sum_nEW = CALCULATE (
        SUM('Payroll'[FTE])/100,
             FILTER (
                Payroll,
                ( Payroll[Payroll nb] <> 376 )
                    && ( Payroll[Payroll nb] <> 377 )
                    && ( Payroll[Payroll nb] <> 445 ) //exclude 3 specifics employees Expat
                    && 'Payroll'[Most Recent Hire Date] <= MAX ( Calendar[Date] )
                    && (
                        ISBLANK ( 'Payroll'[Administrative End Date] )
                            || 'Payroll'[Administrative End Date] >= MAX ( Calendar[Date] )
                    )))
FTE _NEW = SUMX(VALUES('Calendar'[Month]),[sum_nEW])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

It worked properly. 

 

Thanks a lot. 

 

It was getting me nuts, i could not understand why the sum was not correct... 

@Anonymous Great to see it workes, that's exactly what my first reply. Cheers



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous

 

Use another calculate after the calculate function that you aleardy have and this will do the trick:

 

FTE = SUMX (
    VALUES ( 'Calendar'[Month] ),
    CALCULATE (
         CALCULATE(SUM(Payroll[FTE]))/100,
             FILTER (
                Payroll,
                ( Payroll[Payroll nb] <> 376 )
                    && ( Payroll[Payroll nb] <> 377 )
                    && ( Payroll[Payroll nb] <> 445 ) //exclude 3 specifics employees Expat
                    && 'Payroll'[Most Recent Hire Date] <= MAX ( Calendar[Date] )
                    && (
                        ISBLANK ( 'Payroll'[Administrative End Date] )
                            || 'Payroll'[Administrative End Date] >= MAX ( Calendar[Date] )
                    )
            )
        )
    )
parry2k
Super User
Super User

@Anonymous there are many posts related to this, here is one, hope it is helpful



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k 

 

Thanks for reply, but it won't help me as I have some conditionsin the formula and it's not a simple SUM. 

@Anonymous it would, try this, create a seperate measure for SUM and then another measure with SUMX and using existing created sum measure in your sumx. It is all about the filter context. I would do it for you but bit busy with something else right now.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous based on your data i just did what i explained earlier and this is the result i'm getting

 

S = sum with filter you provided in original post

X = SUMX using S

 

totalsum.PNG



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k

 

Thanks for your help, but the result you get it's wrong, you're getting as result for FTE in JAN 3.11 but the right figure for JAN is 499.29 

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.