Search code examples
daxpowerpivot

Using SELECTEDVALUE with PowerPivot instead of Power BI


I moved a report from Power BI to Power Pivot, but the formula of SELECTEDVALUE does not exist in Power Pivot. Can you help correct to a function that works in Power Pivot?

las_val = 
VAR y =
    SELECTEDVALUE ( DateTime[Gasday] )
RETURN
    CALCULATE (
        HEML_TTF_PRICE_V[TTF_DA_WE],
        TOPN (
            1,
            FILTER (
                ALLSELECTED ( DateTime[Gasday] ),
                DateTime[Gasday] <= y
                    && NOT ( ISBLANK ( HEML_TTF_PRICE_V[TTF_DA_WE] ) )
            ),
            DateTime[Gasday], DESC
        )
    )

Solution

  • SELECTEDVALUE is a newer function that's a shortcut for

    IF ( HASONEVALUE ( DateTime[GasDay] ), VALUES ( DateTime[GasDay] ) )