Forum Discussion
DAX countrows Time inteligence
- 2 years ago
Realmente como você observou, fiz as devidas correções e pude ver as linhas sendo contadas.
Obrigado novamente.
Aprecio sua resposta em esclarecer a necessidade de ter colunas calculadas e ter variáveis na DAX, entretanto devido a outros motivos não pude subir com sucesso o arquivo que gostaria de trabalhar (desculpe por isso), mas ele está disponível aqui: (excluído)
Tentei replicar sua ajuda/medida na tabela onde irei trabalhar que é "fProdutividade" relacionando ela com a tabela tipo calendário "CALENDARIOPQ", porém a DAX não conseguiu contar as linhas. (Destaque abaixo)
Meu obejtivo é: contar o número de linhas de "Id_PREA", desde que: a "DataTratamento" de cada "Id_PREA" seja dia útil e também seja de dois dias atrás em relação à data de hoje (data em que o relatório é atualizado).
Observe que a tabela "CALENDARIOPQ" vem do Power Query (para poder incluir uma lista de feriados para melhor atender à minha demanda).
Novamente muito obrigado pela sua ajuda e esclarecimentos.
Hi, jaylsonphb
Thank you very much for your reply. The reason why this measure doesn't work is because the calendar table has the hours, minutes, and seconds after the date are all 12:00:00, as shown in the following image:
This doesn't match the hours, minutes, and seconds after your actual date column, so it's shown empty:
So we can change the original DAX expression like this:
countID =
VAR vDiaUtil = SELECTCOLUMNS(FILTER('CALENDARIOPQ','CALENDARIOPQ'[DiaUtil]=1),'CALENDARIOPQ'[Data])
VAR vLegado = DATEDIFF(SELECTEDVALUE(fProdutividade[DataTratamento]),TODAY(),DAY)
RETURN IF(vLegado>=2,COUNTAX(FILTER(ALLSELECTED(fProdutividade),'fProdutividade'[Id_PREA]<=SELECTEDVALUE(fProdutividade[Id_PREA])&&DATEVALUE(FORMAT('fProdutividade'[DataTratamento],"MM/DD/YYYY")) IN vDiaUtil),'fProdutividade'[Id_PREA]))
In this DAX expression, I first use the format function to convert your date column to MM/DD/YYYY format. Since the format function returns a text date, I used the datevalue function. The main purpose of this function is to change the date of the text type to the date type, so that it can be compared with the vDiaUtil.
The results are as follows:
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- jaylsonphb2 years agoRegular Visitor
Realmente como você observou, fiz as devidas correções e pude ver as linhas sendo contadas.
Obrigado novamente.