Forum Discussion

zahlenschubser's avatar
1 year ago
Solved

Using dimdate table to filter main table with varying "in use" time frames and quantities

I have a main table with shipped / in use items with different timeframes, monthly, quarterly, yearly and a start and end date and the corresponding quantities.   What I would like to do is use my ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi zahlenschubser ,

     

    Thanks for the reply from Thejeswar / Akash_Varuna .

     

    You want to filter the entire selected time period (e.g., month, quarter, year), right? If so you will need to adjust the metric to take into account the entire date range within those periods, you should use both MIN and MAX to capture the entire range.

     

    Modify the measure syntax as follows:

    UseCount = 
    VAR SelectedStartDate = MIN('DimDate'[Date])
    VAR SelectedEndDate = MAX('DimDate'[Date])
    RETURN
        SUMX(
            FILTER(
                'kontext',
                'kontext'[startdate] <= SelectedEndDate &&
                'kontext'[enddate] >= SelectedStartDate
            ),
            'kontext'[quantity]
        )

     

    Here's my test data:

     

    The final page visualization is shown below:

     

    If my understanding is wrong, please describe more clearly (in screenshot or table form) the expected result you want.

     

    The pbix file is attached.

     

    If you have any other questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!