Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Selectively filtering events based upon overlapping date ranges and nested conditions

Let me start by saying I have found a messy, multi-step solution of IF, CALCULATE and FILTER for this but it is an ugly, expensive process and I feel like there must be a simpler way....   Essentia...
  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi Anonymous,

     

    Sorry for the delay response!:smileyhappy:

     

    I have went through the sample pbix file shared above. May I ask how do you want to show these data on the report?

     

    I am just wondering whether using the Merge Queries option in Query Editor to merge these two tables into a single one could meet your requirement in this scenario.

     

    Following is the merged table.

     

     

    Then we can add a calculate column in the Merged table to indicate if the ExternalData.StartDate and ExternalData.EndDate should be replaced by PowerAppData.StartDate and PowerAppData.EndDate.

    Flag = 
    IF (
        ISBLANK ( MergeTable[PowerAppData.StartDate] )
            && ISBLANK ( MergeTable[PowerAppData.EndDate] ),
        BLANK (),
        IF (
            ( MergeTable[PowerAppData.StartDate] >= MergeTable[ExternalData.StartDate]
                && MergeTable[PowerAppData.StartDate] <= MergeTable[ExternalData.EndDate] )
                || ( MergeTable[PowerAppData.EndDate] >= MergeTable[ExternalData.StartDate]
                && MergeTable[PowerAppData.EndDate] <= MergeTable[ExternalData.EndDate] ),
            "Replace",
            "Keep"
        )
    )

     

    Last, show the data with a Slicer of the "Flag" column on the report.

    Here is the modified sample pbix file for your reference.

     

    Regards