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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors