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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FrancoIVM
New Member

Use the current row date

Hi,

I want to calculate the last price from a column filter by date, but i want that the dates that are being evaluated ends at the current date of the row.

 

something like:

Last price bt = CALCULATE(
LASTNONBLANKVALUE(
table[dates],
SUM(table[prices])),
DATESBETWEEN(table[dates],FIRSTDATE(table[dates]),
"""end_date"""))
 
I want that end_date can be the date of the current row if that is posible. Like:
Table:
[Dates] [Price] [Last price] [Last price bt]  
1-1-1    100          150             100
1-1-2                    150             100
1-1-3                    150             100
1-1-4     120         150             120
1-1-5     150         150             150
 
 
 
 
1 ACCEPTED SOLUTION
DataZoe
Employee
Employee

Hi @FrancoIVM , please try this measure:

Previous Price =
CALCULATE (
    LASTNONBLANKVALUE (
        'Table'[Dates],
        [Unit Price]
    ),
    FILTER (
        ALLSELECTED ( 'Table'[Dates] ),
        ISONORAFTER (
                'Table'[Dates], MAX ( 'Table'[Dates] )DESC
        )
    )
)

DataZoe_0-1601943948717.png

 

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

1 REPLY 1
DataZoe
Employee
Employee

Hi @FrancoIVM , please try this measure:

Previous Price =
CALCULATE (
    LASTNONBLANKVALUE (
        'Table'[Dates],
        [Unit Price]
    ),
    FILTER (
        ALLSELECTED ( 'Table'[Dates] ),
        ISONORAFTER (
                'Table'[Dates], MAX ( 'Table'[Dates] )DESC
        )
    )
)

DataZoe_0-1601943948717.png

 

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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