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
unnijoy
Post Partisan
Post Partisan

HC based on Quater

Hi I have a data base with country name, quarter , employee name and HC.

 

Every quarter we will update the HC. Below is the table. I need a formula that will calculate the HC based on the quarter that we select. IF all quarter is selected then it should show the HC based on the latest quarter.

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

 

Qtr 1 2019 Qtr 2 2019
CountryHC CountryHC
India234 India456
Canada324 Canada653
1 ACCEPTED SOLUTION

Hi @unnijoy ,

I modified the formulas. Please try and check if it is what you want?

HC =
VAR vHC =
    CALCULATE (
        MAX ( 'Table'[HC] ),
        FILTER ( 'Table', 'Table'[Qtr] = SELECTEDVALUE ( 'Slicer Table'[Qtr] ) )
    )
RETURN
    IF ( HASONEFILTER ( 'Slicer Table'[Qtr] ), vHC, MAX ( 'Table'[HC] ) )


Count of Awardees =
CALCULATE (
    COUNT ( 'Table'[Emp] ),
    ALLEXCEPT ( 'Table', 'Table'[Country], 'Table'[Qtr] )
)


Percentage = DIVIDE([Count of Awardees],[HC])

2.PNG

For more details, please see the attachment.

 

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

6 REPLIES 6
v-xuding-msft
Community Support
Community Support

Hi @unnijoy ,

Please have a try like this :

  • Create a new table 
Slicer Table = VALUES('Table'[Qtr])
  • Create a measure
Measure =
VAR slicer =
    SELECTEDVALUE ( 'Slicer Table'[Qtr] )
VAR vMaxQtr =
    MAXX ( ALL ( 'Slicer Table' ), MAX ( 'Slicer Table'[Qtr] ) )
VAR vHC =
    CALCULATE ( SUM ( 'Table'[HC] ), FILTER ( 'Table', 'Table'[Qtr] = slicer ) )
VAR vLatestHC =
    SUMX ( FILTER ( 'Table', 'Table'[Qtr] = vMaxQtr ), SUM ( 'Table'[HC] ) )
RETURN
    IF ( HASONEFILTER ( 'Slicer Table'[Qtr] ), vHC, vLatestHC )

1.PNG

For more details, please see the attachement.

 

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

@v-xuding-msft  thanks for the help. Can we change the formula in such a way thta i can get the HC like Quarter 2 2019  India = 456.

 

Why because am i the list of people how got award so i have to divide the count of awardees / HC of the country for a particulr month. 

For example Qtr  2 2019 India totla number of awardees is 200

We are calculating the award % by total number of awardees/ HC of that purticular quarter. so in this case it will be

 

200/456=43.85%.

 

If are selecting all quarter then the HC should be for the latest quarter.

Please help

 

Hi @unnijoy ,

I modified the formulas. Please try and check if it is what you want?

HC =
VAR vHC =
    CALCULATE (
        MAX ( 'Table'[HC] ),
        FILTER ( 'Table', 'Table'[Qtr] = SELECTEDVALUE ( 'Slicer Table'[Qtr] ) )
    )
RETURN
    IF ( HASONEFILTER ( 'Slicer Table'[Qtr] ), vHC, MAX ( 'Table'[HC] ) )


Count of Awardees =
CALCULATE (
    COUNT ( 'Table'[Emp] ),
    ALLEXCEPT ( 'Table', 'Table'[Country], 'Table'[Qtr] )
)


Percentage = DIVIDE([Count of Awardees],[HC])

2.PNG

For more details, please see the attachment.

 

Best Regards,

Xue Ding

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

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

hi @v-xuding-msft ,

 

When i update the bi with new data i can see that i have the latest data till up to Qtr 3 2020. I put the country in X axis and % as vlaues. And i keep QTR as filter. Q3 2020 data is only availabe for India. But when i select all the quarter as per the above formula it show show the graph with QTR 3 2020 data. But currently it is showin all the available country. I mean India with QTR 3 2020 data and the other country with QTR 2 2019. Hoe can i modify the formula so that when i select all QTR it show show the latest QTR data. In our case QTR 3 2020. The countries with no QTR 3 2020 data show not come.

@v-xuding-msft 

 

Thank you very much 🙂

You're welcome.😉

 

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

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.