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
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
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.