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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RaphaelQueiroz
Frequent Visitor

How to bring the price between dates?

Hi, I have two tables, one has de prices of my company by iten, the another one has de price of others companies.

For example:

This is my company table

 

 

This is others companies's table

 

This is the result that I want (5th Collumm) 



The function that I'm using is:

Preço Empresa = CALCULATE(MEDIAN(TBhistorico_preco_venda[DFpreco]);FILTER(ALL(dCalendario);dCalendario[DATA]<=EARLIER(TBconcorrente_preco[Data])))

But the result are ignoring the date and bring the median of all serie.
So, how can I bring the DFpreço in my company table to my others companies table, taking into account the dates?

Thanks for the Help

1 ACCEPTED SOLUTION
rafaelmpsantos
Responsive Resident
Responsive Resident

This one

Medida =
var datamaxima = calculate(LASTDATE(tabelaprecosempresa[DFdata_alteracao]);filter(all(tabelaprecosempresa[DFdata_alteracao]);tabelaprecosempresa[DFdata_alteracao]<=SELECTEDVALUE(tabelaprecosconcorrente[Data Coleta])))
return
CALCULATE(AVERAGE(tabelaprecosempresa[DFpreco]);filter(ALL(tabelaprecosempresa);tabelaprecosempresa[DFdata_alteracao]=datamaxima && tabelaprecosempresa[DFcod_item_estoque]=SELECTEDVALUE(tabelaprecosconcorrente[DFcod_item_estoque])))

View solution in original post

3 REPLIES 3
rafaelmpsantos
Responsive Resident
Responsive Resident

This one

Medida =
var datamaxima = calculate(LASTDATE(tabelaprecosempresa[DFdata_alteracao]);filter(all(tabelaprecosempresa[DFdata_alteracao]);tabelaprecosempresa[DFdata_alteracao]<=SELECTEDVALUE(tabelaprecosconcorrente[Data Coleta])))
return
CALCULATE(AVERAGE(tabelaprecosempresa[DFpreco]);filter(ALL(tabelaprecosempresa);tabelaprecosempresa[DFdata_alteracao]=datamaxima && tabelaprecosempresa[DFcod_item_estoque]=SELECTEDVALUE(tabelaprecosconcorrente[DFcod_item_estoque])))

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @RaphaelQueiroz,

 

Please try this:

Preço Empresa =
CALCULATE (
    MEDIAN ( TBhistorico_preco_venda[DFpreco] ),
    FILTER (
        ALL ( TBhistorico_preco_venda ),
        TBhistorico_preco_venda[Dfdata_alteracao]
            <= EARLIER ( TBconcorrente_preco[DataColeta] )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

Does not work. He brings the average of all period, ignoring the date or the cod.

P.s.: When I put MEDIAN in function above, I would like to say AVERAGE.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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