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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
unnijoy
Post Partisan
Post Partisan

HC calculation

Hi @amitchandak 

 

CountryQtrEmpHC
IndiaQtr 1 2019Sam234
IndiaQtr 1 2019Raj234
IndiaQtr 1 2019kit234
IndiaQtr 1 2019mas234
IndiaQtr 1 2019den234
CanadaQtr 1 2019Dax324
CanadaQtr 1 2019fix324
CanadaQtr 1 2019nick324
CanadaQtr 1 2019rick324
IndiaQtr 2 2019Sam456
IndiaQtr 2 2019Raj456
IndiaQtr 2 2019kit456
IndiaQtr 2 2019mas456
IndiaQtr 2 2019den456
CanadaQtr 2 2019Dax653
CanadaQtr 2 2019fix653
CanadaQtr 2 2019nick653
CanadaQtr 2 2019rick653

 

Above is my data base .

 

I want a formula which will give me the HC like if am selecting Qtr 1 2019 then 

India HC= 234

Canada HC = 324

And if am selecting both Qtr 1 2019 and Qtr 2 2019 then the HC sholuld be the latest HC that is Qtr 2 2019.

India456
Canada653

 

8 REPLIES 8
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to create a seperate slicer table first:

Slicer Table = DISTINCT(SELECTCOLUMNS('Table',"Qtr",'Table'[Qtr]))

Then try this measure:

Measure = 
SWITCH (
    TRUE,
    SELECTEDVALUE ( 'Slicer Table'[Qtr] ) = "Qtr 1 2019", IF ( MAX ( 'Table'[Qtr] ) = SELECTEDVALUE ( 'Slicer Table'[Qtr] ), 1, 0 ),
    SELECTEDVALUE ( 'Slicer Table'[Qtr] ) = "Qtr 2 2019", IF ( MAX ( 'Table'[Qtr] ) = SELECTEDVALUE ( 'Slicer Table'[Qtr] ), 1, 0 ),
    DISTINCTCOUNT ( 'Slicer Table'[Qtr] )
        = CALCULATE ( COUNTROWS ( 'Slicer Table' ), ALL ( 'Slicer Table' ) ), IF (
        MAX ( 'Table'[Quarter] ) = MAXX ( ALL ( 'Table' ), 'Table'[Quarter] ),
        1,
        0
    )
)

Then apply it to the table visual by setting measure=1, when select one value in slicer, the result shows:

61.PNG

62.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto

@v-gizhi-msft ,

 

Thanks for the quick reply.

 

Here we have fixed it to only 2 quarter. Qtr 1 2019 and Qtr 2 2019.

But our data will keep on increasing. So other quarters will also come. So how can we make this dynamic. Like if we have quarter data from 2019 till date and if we select all it should show latest quarter HC or if we are selecting only a particulr quarter then it shoud show that quarter HC

 

Please help.

Hi,

 

Please try to create two columns first:

 

Year = RIGHT(RIGHT('Table'[Qtr],6),4)
Quarter = LEFT(RIGHT('Table'[Qtr],6),1)

 

Then try this measure:

 

Measure = 
SWITCH (
    TRUE,
    MAX ( 'Table'[Qtr] ) = SELECTEDVALUE ( 'Slicer Table'[Qtr] ), 1,
    DISTINCTCOUNT ( 'Slicer Table'[Qtr] )
        = CALCULATE ( COUNTROWS ( 'Slicer Table' ), ALL ( 'Slicer Table' ) ), IF (
        MAX ( 'Table'[Quarter] ) = MAXX ( ALL ( 'Table' ), 'Table'[Quarter] )
            && MAX ( 'Table'[Year] ) = MAXX ( ALL ( 'Table' ), 'Table'[Year] ),
        1,
        0
    )
)

 

And this measure can adapt any new data by Qtr.

Hope this helps.

 

Best Regards,

Giotto

@v-gizhi-msft  thank you very much.

 

Can you add this in the powerbi file and share it with me. so it will be very helpfull for me.

 

Waiting for your reply

Hi,

 

I am sorry to have kept you waiting, here is my test pbix file:

pbix 

If my answer has solved your issue, please mark it as a solution for others to see.
Thanks!

 

Best Regards,

Giotto

@v-gizhi-msft  I am not able to use this to calculate the %.

 

We are caculating the award % using the below Formula.

 

Awardf %= total award/ HC for that quarter,

 

But when i use the current formula i am getting wrong figure.

Please help.

Hi,

 

For your requirement, i add some new data to original table:

160.PNG

Then try this measure:

Total Award/HC = SUM('Table'[Award])/MAX('Table'[HC])

It works well here:

153.PNG

If you want to contract the HC value, just try this:

_HC = CALCULATE(MAX('Table'[HC]),FILTER('Table',[Measure]=1))

Hope this helps.

 

Best Regards,

Giotto

Hi @v-gizhi-msft ,

 

thanks for the reply.

 

Total award is counted by the count of employees.

 so in the below table if we gave employee id it will make our calculation easy.

 

So total award = count of employee id

I tried the formula that you gave. the issue is that the vale is not changing. it is always showing the latest month HC

can you please show it in a powerbi file and share it with me

 

Can you use the formul in graph as below

X axis = Country name

Value = count of employee ID/ HC

Note: HC = HC of the selected quarter. IF all quarter is selectd then it should take Latest month HC.

 

Please share the powerbi file also.

I am using link and stacked column chart in powerbi.

 

Thanks and sorry for asking all this modification. Today is my project deadline data. Thank you:

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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