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

regra para calculo utilizando tabela de historico funcionario

Olá 

 

Preciso de ajuda para criar uma regra que traga a soma de funcionarios ativos mes a mes e ano a ano. 

 

lorran_1-1626719918864.png

CHAPA = FUNCIONARIO

Preciso de um gráfico que me traga quantos funcionários eu tinha baseado no histórico de cada um.

 

Por exemplo:

 

No Mês 4 de 2011 eu tinha: 4 Ativos

 

A chapa 3 e 2 não entram pois a ultima situação (datamudanca) é "D"

 

E eu precisaria de um gráfico que trouxesse esses dados mês a Mês

 

por exemplo: no Mês 1 de 2011 o resultado seria: 3 --- LINHAS 3,5 e 6

 

 

O resultado seria este para o exemplo acima: 

 

lorran_2-1626719969090.png

 

 

 

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @lorran 

I have a test by your sample. Firstly we need to build a calendar table.

Date =
ADDCOLUMNS (
    CALENDAR ( DATE ( 2011, 01, 01 ), DATE ( 2011, 02, 28 ) ),
    "Year", YEAR ( [Date] ),
    "Month", MONTH ( [Date] ),
    "Month-Year", FORMAT ( [Date], "MMM-YY" ),
    "YearMonth",
        YEAR ( [Date] ) * 100
            + MONTH ( [Date] )
)

Then build a measure to get result.

Measure = 
VAR _MaxDate = MAX('Date'[Date])
VAR _T = SUMMARIZE(FILTER(ALL(Sheet3),Sheet3[DATAMUDANICA]<=_MaxDate&&Sheet3[DATAMUDANICA] = CALCULATE(MAX(Sheet3[DATAMUDANICA]),FILTER(ALL(Sheet3),sheet3[CHAPA] =EARLIER(Sheet3[CHAPA])))),Sheet3[CODCOLIGAD],Sheet3[CHAPA],Sheet3[DATAMUDANICA],Sheet3[NOVASITUACA])
RETURN
COUNTAX(FILTER(_T,[NOVASITUACA]<>"D"),[CODCOLIGAD])

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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

2 REPLIES 2
lorran
Frequent Visitor

Sensacional! 

Me ajudou perfeitamente, muito obrigado meu amigo. 

 

 

v-rzhou-msft
Community Support
Community Support

Hi @lorran 

I have a test by your sample. Firstly we need to build a calendar table.

Date =
ADDCOLUMNS (
    CALENDAR ( DATE ( 2011, 01, 01 ), DATE ( 2011, 02, 28 ) ),
    "Year", YEAR ( [Date] ),
    "Month", MONTH ( [Date] ),
    "Month-Year", FORMAT ( [Date], "MMM-YY" ),
    "YearMonth",
        YEAR ( [Date] ) * 100
            + MONTH ( [Date] )
)

Then build a measure to get result.

Measure = 
VAR _MaxDate = MAX('Date'[Date])
VAR _T = SUMMARIZE(FILTER(ALL(Sheet3),Sheet3[DATAMUDANICA]<=_MaxDate&&Sheet3[DATAMUDANICA] = CALCULATE(MAX(Sheet3[DATAMUDANICA]),FILTER(ALL(Sheet3),sheet3[CHAPA] =EARLIER(Sheet3[CHAPA])))),Sheet3[CODCOLIGAD],Sheet3[CHAPA],Sheet3[DATAMUDANICA],Sheet3[NOVASITUACA])
RETURN
COUNTAX(FILTER(_T,[NOVASITUACA]<>"D"),[CODCOLIGAD])

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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.