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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Select data according to certain date

Hi everyone, 

I would ask for your support and knowledge to help me to solve this topic.

I have a set of prices, for few contracts, launched in some dates. I need to filter all the items which its Contract_Month and Contract_Year are above or equal to the latest date's month and year (30/10/2020).

As per example:

DateContract_MonthContract_YearPrice
30/10/202001202110
29/09/20200920202,1
01/08/202001202111
02/06/20200820207
02/06/2020122020

3

Desired output

DateContract_MonthContract_YearPrice
30/10/202001202110
01/08/202001202111
02/06/2020122020

3

Thanks in advance for any help you can give.

Regards,

10 REPLIES 10
camargos88
Community Champion
Community Champion

@Anonymous ,

 

No caso do filtro com 0, se comparar novembro de 2020 com março/abril de 2020 deveria retornar zero, não ?

 

No caso do filtro com 1, os anos são posteriores ao da data_cotacao, não ?

 

Talvez eu tenha entendido a necessidade errada, essa solução compara as datas em cada linha. Se for algo diferente disso, me explique novamente por favor.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



camargos88
Community Champion
Community Champion

@Anonymous ,

 

Dá uma olhada no arquivo anexado.

Criei uma fórmula para comparar as datas e filtrar o visual:

_Filtro = 
VAR _dateCotacao = SELECTEDVALUE('Table'[DATA_COTACAO])
VAR _dateContrato = DATE(SELECTEDVALUE('Table'[Ano_Contrato]), SELECTEDVALUE('Table'[Mês Contrato]), 1)

RETURN IF(_dateContrato >= _dateCotacao, 1, 0)


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Olá @camargos88 ! Vi o ficheiro que enviaste. Quando selecciono o filtro "0", obtenho 3 itens acima da ultima data do mercado. Da mesma forma se seleccionar o filtro "1", a query devolve 6 itens com mes/ano abaixo da ultima data do mercado.DXF_83-PBI_case3.PNGDXF_83-PBI_case2.PNG

camargos88
Community Champion
Community Champion

@Anonymous ,

 

You can create a measure like this:

 

_Filter = 
VAR _date = DATE(SELECTEDVALUE('Table'[Contract_Year]), SELECTEDVALUE('Table'[Contract_Month]),  1)
RETURN IF(_date >= DATE(2020, 10,30), 1, 0)

 

 

 Capture.PNG

 

Use this measure to filter the visual.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Hi @camargos88 ! Thanks for your answer. I think that may succeed, but the date should be the MAX in the Date column, instead of static. I know well, that October 30th is the latestet in the example, but the data model will be updated on a daily basis.

 

Cheers

@Anonymous ,

 

You can replace this block with:

 

CALCULATE(MAX(TABLE[DT_DATE]), ALL(TABLE))



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Hi @camargos88 ! Sorry for the late feedback, but I'm just today coming back to this. I've tried:

ContratosVivos =
VAR _date = DATE(SELECTEDVALUE(UDM_DMO_FORWARD_VALOR[Ano_Contrato]), SELECTEDVALUE(UDM_DMO_FORWARD_VALOR[UDM_DMO_TIPO_CONTRATO.FIM]), 1)
RETURN IF(_date >= (CALCULATE(MAX(UDM_DMO_FORWARD_VALOR[DATA_COTACAO]), ALL(UDM_DMO_FORWARD_VALOR))),1,0).
 
The outcome is still returning items with all the months from 2020, and it should be all the forward months comparing to the latest date from the query.PBI_case1.PNG 
 
What do you suggest to correct this?
 
Thanks once more!

@Anonymous ,

 

você pode colocar uma massa de dados aqui como exemplo ?



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

DATA_COTACAOAno_ContratoVALORCONTRATO_TIPOMês Contrato
22-08-20122012943Ago3
22-08-20122012938Set3
22-08-20122012949Q43
22-08-20122013972Q13
22-08-20122013988Q23
22-08-2012201310135Q33
22-08-20122013104Q43
22-08-2012201410855Cal3
22-08-2012201511345Cal3
22-08-20122012894Ago4
22-08-201220128895Set4
03-11-20202021646Q44
03-11-202020216427Q34
03-11-202020216408Q24
03-11-202020216343Q14
03-11-202020216275Jan4
03-11-202020206215Dez4
03-11-202020206125Nov4
03-11-202020326572Cal3
03-11-202020316572Cal3
03-11-202020306572Cal3
03-11-202020296572Cal3
03-11-202020286572Cal3
03-11-202020276572Cal3
03-11-202020266572Cal3
03-11-202020256346Cal3
03-11-20202024619Cal3
03-11-202020236015Cal3
03-11-202020225685Cal3
03-11-202020215451Cal3
03-11-202020215635Q43
03-11-202020215515Q33
03-11-202020215362Q23
03-11-202020215292Q13
03-11-202020215245Jan3
03-11-20202020518Dez3

 

Anonymous
Not applicable

@camargos88 Na realidade só deverão aparecer os items que Mês_Contrato > mês da data de cotação, e ano_contrato => que ano da data cotação.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.