Forum Discussion

abhishekrws01's avatar
3 years ago
Solved

Selectedvalue Function returning Null Values

Hello , Please help if possible, I have been trying to solve it for few days now. Its related SelectedValue function.    Context : I have two relational tables i.e. datilyTxdata (fact) and calenda...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi abhishekrws01 ,

     

    I made a simple sample for your reference.

    Sample data:

    Given that the dates in this sample are incomplete. Incomplete dates are not convenient for slicer filtering. Let's create a calendar table for the slicer.

    Table 2 = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

    There's no relationship between tables.

    Create a measure to get the sum of sales for the last 6 weeks based on the selected date.

    Sales for last 6 weeks =
    VAR _sel =
        SELECTEDVALUE ( 'Table 2'[Date] )
    VAR _date = _sel - 42
    RETURN
        CALCULATE (
            SUM ( 'Table'[Sale] ),
            FILTER ( ALLSELECTED ( 'Table' ), [Date] >= _date && [Date] <= _sel )
        )
    

    When you select a date from the slicer, the measure returns the result.

     

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.