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 (Quotidien) column in the Dim_Date table,  It displays that decimal value. For other criterie within my conditions, it works well. Only when I retrieve Date column where there is an issue.
 Anyone can help me how to solve it ?
Thank you.

  • 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

3 Replies

  • work well to me. i use the same date field in mensure and slicer

     

    chosen date = SELECTEDVALUE(DIM_CALENDARIO[Data])

     

    confirm the type of mensure field, ajust to shortdate

  • Anonymous's avatar
    Anonymous
    Not applicable

    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