Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Having The User Select A Single Date And Use It In A Measure

I want the date function below to be replaced by a user selected date, I was hoping you folks could help me. When I use between dates and select the max date then wrap it in selectedvalue, nothing comes back. Is there any other functions I can try?

Unearned Days =
VAR ue =
    AVERAGEX (
        'Risks On Trans',
        [Days In Trans]
            - (
                DATE ( 2024, 3, 31 ) + 1
                    - RELATED ( 'Transaction'[Effective Date] )
            )
    )
RETURN
    IF ( ue < 0, 0, ue )

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hey guys believe it or not, a simple MAX function worked, by itself. But I learned a lot anyhow. Thanks to all of you.

7 Replies

  • RELATED is something you usually use in calculated columns, not in measures. Your data model should take care of the relationships for the measure calculation.

     

    How does the user select a date?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the info about RELATED. The user would select the date with a between slicer, but they would be instructed to choose one date, if they choose two then the latest one would be used. That's why I was thinking MAX on a date table would work with SELECTEDVALUE.

      • lbendlin's avatar
        lbendlin
        Super User

        MAX can work as a workaround but you will want to go for VALUES in case they select multiple dates. (They will do that, instructions be damned).

  • Hi,

    Try to replace RELATED() with MAX(Calendar[date]).  The between slicer should be built from the Calendar table.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey guys believe it or not, a simple MAX function worked, by itself. But I learned a lot anyhow. Thanks to all of you.

    • v-achippa's avatar
      v-achippa
      Community Support

      Hi Anonymous,

       

      Thank you for reaching out to Microsoft Fabric Community.

       

      Thank you for the response and confirming that the issue is resolved now. I request you to please post the solution here and mark it as a solution so that other community members will find it more easily. If not please accept the above post as a solution.

       

      Thank you lbendlin and Ashish_Mathur for the prompt response.

       

      Thanks and regards,

      Anjan Kumar Chippa