Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Using selected value from one table in a calculation in another table

Hi, I've been struggling with this task in pbi: I have TABLE1 where I have START_DATE and END_DATE. In TABLE2 I generated ALL_DATES for last 2 years till today.   I have a slicer with ALL_DATES ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    Please try below steps:

    1. below is my test table

    Table1:

    Table2:

    Table2 = CALENDAR(DATE(2022,01,01),DATE(2023,2,6))

    2. create a measure with below dax formula

    Measure =
    VAR min_date =
        MINX ( 'Table2', [Date] )
    VAR max_date =
        MAXX ( 'Table2', [Date] )
    VAR tmp =
        FILTER ( ALL ( Table1 ), [Start Date] >= min_date && [End Date] <= max_date )
    RETURN
        SUMX ( tmp, [Sales] )
    

    3. add a slicer with Table2 field, add a card visual with measure

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.