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
gottapu
Frequent Visitor

Employee FTE calculation

Hi,

 

I have data similar to tables below. Fact table that I se connects to number of other dimension tables and so number of rows per each assignment id are much larger but I have simplified it to make it easy to understand my issue.

 

Employee table is joined to Fact table on Employee ID and Assignment Table is joined to fact table on composite key (Assignment ID + Start Date + End Date)

 

HR data.png

 

I am trying to get to an output as below and I am not able to calculate Employee FTE values accurately. Appreciate if you can offer any help as I am new to Power BI and struggling as I have spend few hours on this but could not get it right.

 

Power BI report output
Employee NameAssignment IDAssignment FTEEmployee FTE
A1111
B210.50.7
B220.20.7
C310.30.7
C320.10.7
C330.30.7

 

 

Thank you,

-Raj

2 ACCEPTED SOLUTIONS

@gottapu how about adjust the code like this

wdx223_Daniel_0-1603092309930.png

 

View solution in original post

@gottapu how about changing the code like this?

Employee FTE:=IF(COUNTROWS('Fact'),SUMX(ALL(Assignment[Asgn ID]),CALCULATE(MAX('Fact'[Assignment FTE]),ALL(RepGroup[Rep Group Name]),ALL('Fact'[Assignment FTE]))))

View solution in original post

12 REPLIES 12
amitchandak
Super User
Super User

@gottapu , Try a measure like

 

Employee FTE =calculate(sum(Table[Assignment FTE]), filter(allselected(Table),[Employee Name] = max([Employee Name])))

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Thanks Amit for your quick reply. Unfortunately, after trying above, I am getting Employee FTE as sum of all Assignment FTE values in the fact table and hence they are way more than what I am trying to get. For Employee ID =1, I am getting Employee FTE as value 3.

 

Thanks

-Raj

 

@gottapu i think this code can help you

wdx223_Daniel_0-1603090377100.png

 

Thanks much @wdx223_Daniel. Really appreciate you taking the time to replicate our scenario. Below solution has got me very close. We are displaying Assignment ID from dimension and when we do that Employee FTE and Assignment FTE are now showing same values (Employee FTE values not rolling up). But when we show Assignment ID from fact table, Employee FTE values are rolling up correctly. In reality, we have Assignment Number in our Assignments dimension that we show in our report. Appreciate, if you can let me know how best to adjust code when we are using Assignment ID from Assignment dimension in our report.

 

Thank you

-Raj

@gottapu how about adjust the code like this

wdx223_Daniel_0-1603092309930.png

 

Hi @wdx223_Daniel,

 

I have run into a slight problem where if I bring in additional column from another dimension, FTE values appears to be not rolling up. For example, I have Representation Group dimension that is connected to my fact on Rep group id field. For Example, Assignment IDs 21 has a representation group of 'Faculty' value and and Assignment ID 22 as a representation group of 'Clinician'. Though representation groups are at the assignment level, they are connected to Fact table using a different key (i.e Rep ID). Is there a way I can include Representation group in my report but still calculate FTE by Employee?

 

Output that I am looking for:

Employee NameAssignment IDRep GroupAssignment FTEEmployee FTE
A11Faculty11
B21Faculty0.50.7
B22Clinician0.20.7
C31Faculty0.30.7
C32Clinician0.10.7
C33MG Fcaulty0.30.7

 

 

Rep Group Table:

Rep Group IDRep Group Name
1Faculty
2MG Faculty
3Clinician

 

 

For Employee B and C, I am getting same values for Employee FTE and Assignment FTE. Apreciate any further help.

 

Thanks,

-Raj

 

 

@gottapu how about changing the code like this?

Employee FTE:=IF(COUNTROWS('Fact'),SUMX(ALL(Assignment[Asgn ID]),CALCULATE(MAX('Fact'[Assignment FTE]),ALL(RepGroup[Rep Group Name]),ALL('Fact'[Assignment FTE]))))

Thanks much @wdx223_Daniel. That does the job for me.

 

I just have a follow up question. If I create a measure like this it looks like it only works for coded secnario and if my users drag and drop additional fields from additional dimensions, calculation poentially displays Assignment FTE values under Employee FTE field. Is there a way we can calculate it regardless of what additional columns (from dimensions that I have not specificed in my calc) users add to thier reports?

 

Thanks,

-Raj

 

@gottapu please try this code, i don't think it is the best solution, this measure ignores the assignment id.

Employee FTE2 :=
IF (
    COUNTROWS ( 'Fact' ),
    SUMX (
        VALUES ( Employee[Name] ),
        VAR _eply = Employee[Name]
        RETURN
            SUMX (
                CALCULATETABLE (
                    SUMMARIZE ( 'Fact', 'Fact'[Assignment FTE], Assignment[Asgn ID] ),
                    ALL ( 'Fact' ),
                    Employee[Name] = _eply
                ),
                'Fact'[Assignment FTE]
            )
    )
)

 

@wdx223_Daniel  Thank you so much for all your help. I have used other DAX expression that you have provided and added rest all dimensions under filter condition so that no matter what users add to the report, FTE values are calculated correctly. The summarize expression that you have provided works for Employee FTE but when I slice, it does seem to be ignore those filters and provide me same values and so not optimal for me.

 

Once again, thanks much for taking your time to respond back quickly. I very much appreciate it.

Thanks,

-Raj

@gottapu if you have slicers in the model, you can try to change ALL('FACT') to ALLSELECT('FACT')

Thank you so much @wdx223_Daniel . I have been working on this calc for last few days and breaking my head. I am relatively new to Power BI DAX code. I have gone through Plural sight DAX videos and other DAX documentation available on web but still struggled to get to correct number. You have made my day. Thank you so much for going extra mile to help.

 

Thanks,

-Raj

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.

Top Solution Authors