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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Look for value with multiple conditions

Need help on this Power BI DAX, please see the test Power BI File attached.
 

In the PriceHistory table contains MemberId, Price and the [Date] when the price was captured

In the Member table contain memberId and reporDate.

 

I need to calculate a column [Price] in the member table to look for the rows for the memberId in PriceHistory table where [Date] is less than the [reportDate] and take the price from the row with max[Date] from the rows.

 
Data in PriceHistory:
mahaitao_pony_0-1660547977172.jpeg

 

 
 
Data in Member:
mahaitao_pony_1-1660547977172.jpeg

 

 
 
Expecting result:
mahaitao_pony_0-1660549459595.png

 


 

 
The tricky parts the price captured for Member Id 3 on 1st Jun 2022 will be used for both July and Aug report as there is no new price captured for Member 3
after 1st Jun 2022
 
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

Try this calculated column in table Member:

 

Price = 
VAR vMemberId = 'Member'[MemberId]
VAR vReportDate = 'Member'[reportDate]
VAR vTable =
    FILTER (
        PriceHistory,
        PriceHistory[MemberId] = vMemberId
            && PriceHistory[Date] < vReportDate
    )
VAR vMaxDate =
    MAXX ( vTable, PriceHistory[Date] )
VAR vResult =
    MAXX ( FILTER ( vTable, PriceHistory[Date] = vMaxDate ), PriceHistory[Price] )
RETURN
    vResult

 

DataInsights_0-1660586688603.png

 





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

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@Anonymous,

 

Try this calculated column in table Member:

 

Price = 
VAR vMemberId = 'Member'[MemberId]
VAR vReportDate = 'Member'[reportDate]
VAR vTable =
    FILTER (
        PriceHistory,
        PriceHistory[MemberId] = vMemberId
            && PriceHistory[Date] < vReportDate
    )
VAR vMaxDate =
    MAXX ( vTable, PriceHistory[Date] )
VAR vResult =
    MAXX ( FILTER ( vTable, PriceHistory[Date] = vMaxDate ), PriceHistory[Price] )
RETURN
    vResult

 

DataInsights_0-1660586688603.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors