Forum Discussion

Randcharles's avatar
Randcharles
Icon for Helper I rankHelper I
2 years ago
Solved

My Date column cannot be retrieved from SELECTEDVALUE

Hi all, I am facing on a new issue when I want to retrieve the Date from my table Dim_Date using SELECTEDVALUE().  Indeed, when I display the result of my SELECTEDVALUE() from my Date (Quot...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Randcharles ,

    As checked your screenshot, the measure [#Test] will return option values for different fields depending on the value of variable _Periodicite, and it appears that the data type of the measure is counted as General. However, you need to return a value that contains multiple types: a date (Dim_Date[Quotidien]), a numeric value and possibly a Text type.

    You can update the formula of measure [#Test] as below to get the expected result...

    #Test =
    VAR _Periodicite =
        MAXX (
            'Param_Periodicite',
            'Param_Periodicite'[Periodicite Order]
                = SELECTEDVALUE ( 'Param_Periodicite'[Periodicite Order] ),
            'Param_Periodicite'[Periodicite]
        )
    RETURN
        SWITCH (
            TRUE (),
            _Periodicite = "Mensuel", SELECTEDVALUE ( Dim_Date[Mensuel] ),
            _Periodicite = "Hebdo", SELECTEDVALUE ( Dim_Date[Hebdo] ),
            _Periodicite = "Quotidien", FORMAT ( SELECTEDVALUE ( Dim_Date[Quotidien] ), "MM/DD/YYYY" )
        )

    Best Regards