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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Nethergate
New Member

Duplicated records - fixed row

Happy new year guys. I have a bit of a sticker issue per below.

  • Background: I have the below source data with the cost by Account and headcount is based on cost center.
  • Objective: I wish to derive the cost per HC such that I can change the view to easily for analysis
  • Issue:
    • However, the problem is that the headcount by cost center is duplicative due to multiple Account type in the records. For example, physically in Feb, I only have 5 headcount in Cost Center C. But PowerBi would sum up the records and show me 10 headcount, which is incorrect
    • Another example is physically in Jan, I only have 1 headcount in Australia but PowerBi would sum up the records and show me 2 headcount, which is incorrect
    • I wish to be able to change the view freely so that I can see the cost per FTE by different cuts for analysis

Really appreciate your help on this ! 

 

Source data

Nethergate_2-1640996737640.png

 

Source data (editable version)

CountryCost CenterMonthAccountCostHeadcount by cost centerCost per HC
AustraliaAJanpayroll           1001100
AustraliaAJanbonus           1001100
AustraliaAFebpayroll           200367
AustraliaBFebpayroll           200450
SingaporeCFebpayroll           200540
SingaporeCFebbonus           200540
Correct Total          1,000                       1377
Incorrect total          1,000                       1953

 

 

Correct Desired view 1

Nethergate_3-1640996753743.png

Correct Desired view 2

Nethergate_4-1640996766249.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Nethergate ,

Here are the steps you can follow๏ผš

Correct Desired view 1๏ผš

1. Use Enter data to create a table

vyangliumsft_0-1641368266024.png

2. Create measure.

Sum_Month_Jan =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
Sum_Month_Feb =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
Sum_Month_group = CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])))
Sumโ€”Headcount-month_Jan =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
Sumโ€”Headcount-month_Feb =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
Sumโ€”Headcount-month-group =
[Sumโ€”Headcount-month_Jan] + [Sumโ€”Headcount-month_Feb]
sum_costperHc_month_Jan =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
sum_costperHc_month_Feb =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
sum_costperHc_month_group =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])))
Flag =

VAR _1=
SWITCH(
TRUE(),
SELECTEDVALUE('Slice'[Index]) =1,[Sum_Month_Jan],
SELECTEDVALUE('Slice'[Index]) =2,[Sum_Month_Feb],
SELECTEDVALUE('Slice'[Index]) =3,[Sum_Month_group],
SELECTEDVALUE('Slice'[Index]) =4,[Sumโ€”Headcount-month_Jan],
SELECTEDVALUE('Slice'[Index]) =5,[Sumโ€”Headcount-month_Feb],
SELECTEDVALUE('Slice'[Index]) =6,[Sumโ€”Headcount-month-group],
SELECTEDVALUE('Slice'[Index]) =7,[sum_costperHc_month_Jan],
SELECTEDVALUE('Slice'[Index]) =8,[sum_costperHc_month_Feb],
SELECTEDVALUE('Slice'[Index]) =9,[sum_costperHc_month_group])
RETURN
IF( ISBLANK([Sum_Month_Jan])&&ISBLANK([Sum_Month_group])&&ISBLANK([Sumโ€”Headcount-month_Jan])&&ISBLANK([Sumโ€”Headcount-month-group])&&ISBLANK([sum_costperHc_month_Jan]),BLANK(),_1)

3. Select [HybridColumns] column, click [Column tools] โ€“ Sort by column โ€“ [lndex]

vyangliumsft_1-1641368266029.png

4. Result:

vyangliumsft_2-1641368266040.png

Correct Desired view 2๏ผš

1. Use Enter data to create a table

vyangliumsft_3-1641368266040.png

2. Create measure.

Country_Month_Jan =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Jan"))
Country_Month_Feb =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb"))
Country_Month_group = CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])))
Country_Headcount-month_Jan =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Jan"))
Country_Headcount-month_Feb =
IF(
    MAX('Table'[Country])="Australia",
CALCULATE(SUM('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb")),
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb")))
Country_Headcount-month-group =
[Country_Headcount-month_Jan]+[Country_Headcount-month_Feb]
Country_costperHc_month_Jan =
IF(
    MAX('Table'[Country])="Australia",BLANK(),"#DIV/0!")
Country_costperHc_month_Feb =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb"))
Country_costperHc_month_group =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])))
Flag2 =
VAR _1=
SWITCH(
TRUE(),
SELECTEDVALUE('Desired view'[Index])=1,[Country_Month_Jan],
SELECTEDVALUE('Desired view'[Index]) =2,[Country_Month_Feb],
SELECTEDVALUE('Desired view'[Index]) =3,[Country_Month_group],
SELECTEDVALUE('Desired view'[Index]) =4,[Country_Headcount-month_Jan],
SELECTEDVALUE('Desired view'[Index])=5,[Country_Headcount-month_Feb],
SELECTEDVALUE('Desired view'[Index])=6,[Country_Headcount-month-group],
SELECTEDVALUE('Desired view'[Index])=7,[Country_costperHc_month_Jan],
SELECTEDVALUE('Desired view'[Index])=8,[Country_costperHc_month_Feb],
SELECTEDVALUE('Desired view'[Index])=9,[Country_costperHc_month_group])
RETURN
IF( ISBLANK([Country_costperHc_month_Jan])&&ISBLANK([Country_costperHc_month_group])&&ISBLANK([Country_Headcount-month_Jan])&&ISBLANK([Country_Headcount-month-group])&&ISBLANK([Country_costperHc_month_Jan]),BLANK(),_1)

3. Select [HybridColumns] column, click [Column tools] โ€“ Sort by column โ€“ [lndex]

vyangliumsft_4-1641368266043.png

4. Result:

 

vyangliumsft_5-1641368266045.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @Nethergate ,

Here are the steps you can follow๏ผš

Correct Desired view 1๏ผš

1. Use Enter data to create a table

vyangliumsft_0-1641368266024.png

2. Create measure.

Sum_Month_Jan =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
Sum_Month_Feb =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
Sum_Month_group = CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])))
Sumโ€”Headcount-month_Jan =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
Sumโ€”Headcount-month_Feb =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
Sumโ€”Headcount-month-group =
[Sumโ€”Headcount-month_Jan] + [Sumโ€”Headcount-month_Feb]
sum_costperHc_month_Jan =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Jan"))
sum_costperHc_month_Feb =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])&&'Table'[Month]="Feb"))
sum_costperHc_month_group =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Cost Center]=MAX('Table'[Cost Center])))
Flag =

VAR _1=
SWITCH(
TRUE(),
SELECTEDVALUE('Slice'[Index]) =1,[Sum_Month_Jan],
SELECTEDVALUE('Slice'[Index]) =2,[Sum_Month_Feb],
SELECTEDVALUE('Slice'[Index]) =3,[Sum_Month_group],
SELECTEDVALUE('Slice'[Index]) =4,[Sumโ€”Headcount-month_Jan],
SELECTEDVALUE('Slice'[Index]) =5,[Sumโ€”Headcount-month_Feb],
SELECTEDVALUE('Slice'[Index]) =6,[Sumโ€”Headcount-month-group],
SELECTEDVALUE('Slice'[Index]) =7,[sum_costperHc_month_Jan],
SELECTEDVALUE('Slice'[Index]) =8,[sum_costperHc_month_Feb],
SELECTEDVALUE('Slice'[Index]) =9,[sum_costperHc_month_group])
RETURN
IF( ISBLANK([Sum_Month_Jan])&&ISBLANK([Sum_Month_group])&&ISBLANK([Sumโ€”Headcount-month_Jan])&&ISBLANK([Sumโ€”Headcount-month-group])&&ISBLANK([sum_costperHc_month_Jan]),BLANK(),_1)

3. Select [HybridColumns] column, click [Column tools] โ€“ Sort by column โ€“ [lndex]

vyangliumsft_1-1641368266029.png

4. Result:

vyangliumsft_2-1641368266040.png

Correct Desired view 2๏ผš

1. Use Enter data to create a table

vyangliumsft_3-1641368266040.png

2. Create measure.

Country_Month_Jan =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Jan"))
Country_Month_Feb =
CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb"))
Country_Month_group = CALCULATE(SUM('Table'[Cost]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])))
Country_Headcount-month_Jan =
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Jan"))
Country_Headcount-month_Feb =
IF(
    MAX('Table'[Country])="Australia",
CALCULATE(SUM('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb")),
CALCULATE(MAX('Table'[Headcount by cost center]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb")))
Country_Headcount-month-group =
[Country_Headcount-month_Jan]+[Country_Headcount-month_Feb]
Country_costperHc_month_Jan =
IF(
    MAX('Table'[Country])="Australia",BLANK(),"#DIV/0!")
Country_costperHc_month_Feb =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])&&'Table'[Month]="Feb"))
Country_costperHc_month_group =
CALCULATE(SUM('Table'[Cost per HC]),FILTER(ALL('Table'),'Table'[Country]=MAX('Table'[Country])))
Flag2 =
VAR _1=
SWITCH(
TRUE(),
SELECTEDVALUE('Desired view'[Index])=1,[Country_Month_Jan],
SELECTEDVALUE('Desired view'[Index]) =2,[Country_Month_Feb],
SELECTEDVALUE('Desired view'[Index]) =3,[Country_Month_group],
SELECTEDVALUE('Desired view'[Index]) =4,[Country_Headcount-month_Jan],
SELECTEDVALUE('Desired view'[Index])=5,[Country_Headcount-month_Feb],
SELECTEDVALUE('Desired view'[Index])=6,[Country_Headcount-month-group],
SELECTEDVALUE('Desired view'[Index])=7,[Country_costperHc_month_Jan],
SELECTEDVALUE('Desired view'[Index])=8,[Country_costperHc_month_Feb],
SELECTEDVALUE('Desired view'[Index])=9,[Country_costperHc_month_group])
RETURN
IF( ISBLANK([Country_costperHc_month_Jan])&&ISBLANK([Country_costperHc_month_group])&&ISBLANK([Country_Headcount-month_Jan])&&ISBLANK([Country_Headcount-month-group])&&ISBLANK([Country_costperHc_month_Jan]),BLANK(),_1)

3. Select [HybridColumns] column, click [Column tools] โ€“ Sort by column โ€“ [lndex]

vyangliumsft_4-1641368266043.png

4. Result:

 

vyangliumsft_5-1641368266045.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.