cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JeniferNunes
Helper I
Helper I

Contar linhas no período entre datas

Olá, poderiam ajudar com essa situação.

Tenho essa pequena tabela para exemplificar.

JeniferNunes_0-1651330769147.png

 

Preciso contar as linhas, para isso uso a COUNTA, e até aí tudo certo, agora vem o problema:
Imagina que estou executando um filtro no Dashboard com a data do dia 15/04/2022.

Preciso que ele conte os itens com os ID's 3, 5, 6. (total de 3)

JeniferNunes_0-1651340030229.png

A situação é contar os itens no estoque nessa data (15/04/2022). Então não posso considerar se entrou ou saiu dia 15, preciso considerar o período "ENTRE" das colunas dtatende e dtsaida.


Se alguém puder ajudar, serei grato. anexo está o fixeiro

 

2 REPLIES 2
amitchandak
Super User
Super User

@JeniferNunes , Assume you have disconnected date table to select dates

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Start Date] <=_max && ('Table'[End Date] >=_max || isblank('Table'[End Date]) ) ))



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Olá @amitchandak obrigado por me ajudar.

Porém não deu carto aqui, não sei se entendi o que quis dizer... Veja como fiz.

 

JeniferNunes_0-1651503274215.png

Coloquei a data de ínicio no dia 12/04/2022 e só apareceu o ID "6", nem os outros ID 3 e 4, que também entram no dia12/04/2022 apareceram...

 

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors
Top Kudoed Authors