Forum Discussion

gabrielvigo's avatar
gabrielvigo
Helper I
8 years ago
Solved

Enter data in variables

Hi everyone!

 

I have a static date filter in one measure.

For ecample: Today() -1.

 

But I need that this filter, Today()-1, calculate about selction date.

I need this, because some measures are specific to that date and others are accumulated until that date.

 

In summary, I need a variable / measure associated with the user's date selection.

  • Hi gabrielvigo,

     

    Try these formulas below.

    Test =
    CALCULATE (
        SUM ( Supply_Chain[Operations Stockouts] );
        FILTER (
            ALL ( 'Calendar'[Fecha] );
            'Calendar'[Fecha] = SELECTEDVALUE ( 'Calendar'[Fecha] )
        )
    )
    
    Test2 =
    CALCULATE (
        SUM ( Supply_Chain[Operations Stockouts] );
        FILTER (
            ALL ( 'Calendar'[Fecha] );
            'Calendar'[Fecha] <= SELECTEDVALUE ( 'Calendar'[Fecha] )
        )
    )
    

    Best Regards,

    Dale

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    So typically you do this with a slicer and something like MAX or SELECTEDVALUE. "What If" measures were created for this purpose.

    • gabrielvigo's avatar
      gabrielvigo
      Helper I

      Hi.

       

      No, I can't calculate them.

       

      I need 2 calculations:

       

      1. Test = CALCULATE(SUM(Supply_Chain[Operations Stockouts]);'Calendar'[Fecha] = SELECTEDVALUE('Calendar'[Fecha]))
      2. Test2 = CALCULATE(SUM(Supply_Chain[Operations Stockouts]);'Calendar'[Fecha] <= SELECTEDVALUE('Calendar'[Fecha]))

       

       

       

      • v-jiascu-msft's avatar
        v-jiascu-msft
        Microsoft Employee

        Hi gabrielvigo,

         

        Try these formulas below.

        Test =
        CALCULATE (
            SUM ( Supply_Chain[Operations Stockouts] );
            FILTER (
                ALL ( 'Calendar'[Fecha] );
                'Calendar'[Fecha] = SELECTEDVALUE ( 'Calendar'[Fecha] )
            )
        )
        
        Test2 =
        CALCULATE (
            SUM ( Supply_Chain[Operations Stockouts] );
            FILTER (
                ALL ( 'Calendar'[Fecha] );
                'Calendar'[Fecha] <= SELECTEDVALUE ( 'Calendar'[Fecha] )
            )
        )
        

        Best Regards,

        Dale