Forum Discussion

RGregory's avatar
RGregory
Regular Visitor
3 years ago
Solved

Filter a Fact Table to Exclude Item Exceptions By Date Range

I have a list of transactions by Date and Item (multiple dates and items) and now I need to exclude certain items based on the date ranges in this second table. (items can appear multiple times - it...
  • Sahir_Maharaj's avatar
    3 years ago

    Hello RGregory,

     

    1. Create a separate table for the exclusion dates with columns for Item, Start Date, and End Date.

     

    2. Create a measure that calculates whether a transaction falls within any of the exclusion date ranges for the item.

     

    Transaction Flag = 
    VAR ItemID = MAX('Transactions'[Item ID])
    VAR TransactionDate = MAX('Transactions'[Transaction Date])
    VAR Exclusions = FILTER(ExclusionDates, ExclusionDates[Item] = ItemID && TransactionDate >= ExclusionDates[Start Date] && TransactionDate <= ExclusionDates[End Date])
    RETURN IF(COUNTROWS(Exclusions) > 0, 1, 0)

     

     

    3. Add the Transaction Flag measure to your visualizations to see which transactions are flagged based on the exclusion dates.

    4. You can also use the measure to filter your data by creating a filter that includes only transactions with a flag of 0 (i.e., transactions that are not excluded).

     

    Let me know if you might require further assistance.