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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
hcmj
Frequent Visitor

Get the latest price not working

I have a price table like the below, which are connected to my calendar table through the field Activationdate in my fact table.
hcmj_0-1692894318588.png

I would like to have the priceamountacc to be the same for each day until a new price is entered for a certain date
09-03-2023   1,88

10-03-2023   1,88

11-03-2023   1,88

....
04-04-2023   1,81
05-04-2023   1,81
etc...

I have tried the following which is actually working on a SSAS Tabular Cube, but when trying to deploying it to a Power BI Dataset it does not work - any help is appreciated

LatestPrice:=
VAR MaxDate = MAX('Calendar'[Date])
VAR LatestClosingValue = CALCULATE(LASTNONBLANK(Fct_UnitPriceTransactions[PriceAmountAcc], 1),
ALLEXCEPT('Calendar','Calendar'[Date] ), 'Calendar'[Date] <= MaxDate)
RETURN LatestClosingValue

1 REPLY 1
johnt75
Super User
Super User

Try

Latest Price =
VAR MaxDate =
    MAX ( 'Calendar'[Date] )
VAR LastRow =
    INDEX (
        1,
        SUMMARIZE (
            Fct_UnitPriceTransactions,
            Fct_UnitPriceTransactions[PriceAmountAcc],
            Fct_UnitPriceTransactions[Activation date]
        ),
        ORDERBY ( Fct_UnitPriceTransactions[Activation date], DESC )
    )
VAR LastPrice =
    SELECTCOLUMNS ( LastRow, Fct_UnitPriceTransactions[PriceAmountAcc] )
RETURN
    LastPrice

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.