Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
marri
Frequent Visitor

Data filtering using multiple date columns of a table

Hi,

 

I need some approaches on the below. I have a tabular model with the table called proposals and

Suppose table proposals have different date columns like initiationdate, responsedate, completeddate.

I will consider calendar table for the date prompt in report

And I have date range filter in report where user prompts Fromdate and Todate

 

Now when a user selects the range in date fitler in powerbi report, the records to be displayed on the visual is from the table proposals with the multiple conditions like where initiationdate between the date range selected in date filter

or responsedate between the date range selected in date filter 

or completeddate between the date range selected in date filter

productidinitiationdateresponsedatecompleteddate
1276/5/20176/9/20176/13/2018
1286/6/20176/10/20176/14/2018
1296/7/20176/15/20176/19/2018
1306/8/20176/16/20176/20/2018
1316/9/20176/17/20176/21/2018
1326/10/20176/18/20176/22/2018
1336/16/20176/19/20176/23/2018
1346/17/20176/20/20176/24/2018
1356/18/20176/21/20176/25/2018
1366/19/20176/22/20176/26/2018
1376/20/20176/23/20176/27/2018
1386/21/20176/24/20176/28/2018

 

date prompt 
FromTo
6/7/20176/14/2017

 

Expected Output:  
productidinitiationdateresponsedatecompleteddate
1276/5/20176/9/20176/13/2018
1286/6/20176/10/20176/14/2018
1296/7/20176/15/20176/19/2018
1306/8/20176/16/20176/20/2018
1316/9/20176/17/20176/21/2018
1326/10/20176/18/20176/22/2018

Please let me know the approach/ideas how shall i design the model and come up with the query

 

Thanks

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @marri,

 

Two approaches here. You can download the demo and try it out.

1. Add a measure and filter the values of the measure. (No relationship between two tables.)

Measure =
VAR initdate =
    MIN ( Table1[initiationdate] )
VAR respdate =
    MIN ( Table1[responsedate] )
VAR comdate =
    MIN ( Table1[completeddate] )
RETURN
    IF (
        (
            initdate >= MIN ( 'Date Prompt'[Date] )
                && initdate <= MAX ( 'Date Prompt'[Date] )
        )
            || (
                respdate >= MIN ( 'Date Prompt'[Date] )
                    && respdate <= MAX ( 'Date Prompt'[Date] )
            )
            || (
                comdate >= MIN ( 'Date Prompt'[Date] )
                    && comdate <= MAX ( 'Date Prompt'[Date] )
            ),
        1,
        0
    )

2. Unpivot the table Proposals. (relationship to Date table is needed.)

Data_filtering_using_multiple_date_columns_of_a_table

 

Best Regards,

Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thankyou for the reply.

I have tried the same way as mentioned in your approach 1( without relationship between time(calendar) and proposals table)

But could not able to see the expected result.

Please find the below screen shot

 

products.PNG

Always Measure displays the value with "0" even though the product_sid's initiationdate, responsedate, completedate falls within the range of date prompt. For example, please verify for the product_sid 35659008, 35659015. The formula which is used is mentioned below

Measure  = VAR initiationdate = MIN(proposals[initiationdate]) VAR responsedate = MIN(proposals[responsedate]) VAR completedate = MIN(proposals[completedate])  RETURN IF (
        (
            initiationdate >= MIN ( 'time'[Date] )
                && initiationdate<= MAX ( 'time'[Date] )
        )
            || (
                proposeddate>= MIN ( 'time'[Date])
                    && proposeddate<= MAX ( 'time'[Date])
            )
            || (
                completedate >= MIN ( 'time'[Date])
                    && completedate <= MAX ( 'time'[Date] )
            ),
        1,
  0
    )

 

Please help me in understanding why does always  measure shows the value 0 instead of displaying 1 even for the records which falls into the date range prompt.

 

 

Approach2:

Proposals table is very large data set with minimum of 16 millions of records. Does unpivot of table proposals and having the relationship with time table works? Please clarify.

 

 

Hi @marri,

 

Did you try out the demo I shared? Can you share your pbix file? It should work.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.