cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AndyTrezise
Helper II
Helper II

Split & filter data from one table into multiple based on a user selected date

Hi All

 

I have a requirement to split / filter a table of transactions into three consecutive date driven periods.

 

My base table consists of tasks for resources on given dates.

 

i.e.

 

John, Project A, Task 1, 01/02/2017

John, Project G, Task 2, 03/04/2017

John, Project D, Task 3, 04/04/2017

John, Project G, Task 4, 30/04/2017

John, Project N, Task 5, 04/05/2017

John, Project A, Task 6, 14/05/2017

John, Project D, Task 7, 10/06/2017

 

So...my requirement is to allow the user to select a year / month from a date slicer (I'm OK with that bit) and then based on the month selected I then want to display 3 seperate tables of data. For example if the user select February 2017 then I want table 1 to display tasks in February, table 2 to display tasks in March and table 3 to display tasks in April etc.

 

I managed to split the table into 3 via the query editor based on todays date but I need it to be more flexible than that and allow a user to select the start month/year and work forward from there. I'm sure there must be a way of creating the tables on the fly or filtering via DAX.

 

Any help would be much appreciated.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@AndyTrezise,

 

You may add three measures and drag them to three tables accordingly. It takes advantage of Show Categories With No Data.

Measure =
VAR d =
    SELECTEDVALUE ( Table1[Date] )
VAR d2 =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    IF (
        d >= DATE ( YEAR ( d2 ), MONTH ( d2 ), 1 )
            && d
                < DATE ( YEAR ( d2 ), MONTH ( d2 ) + 1, 1 ),
        d
    )
Measure2 =
VAR d =
    SELECTEDVALUE ( Table1[Date] )
VAR d2 =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    IF (
        d
            >= DATE ( YEAR ( d2 ), MONTH ( d2 ) + 1, 1 )
            && d
                < DATE ( YEAR ( d2 ), MONTH ( d2 ) + 2, 1 ),
        d
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@AndyTrezise,

 

You may add three measures and drag them to three tables accordingly. It takes advantage of Show Categories With No Data.

Measure =
VAR d =
    SELECTEDVALUE ( Table1[Date] )
VAR d2 =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    IF (
        d >= DATE ( YEAR ( d2 ), MONTH ( d2 ), 1 )
            && d
                < DATE ( YEAR ( d2 ), MONTH ( d2 ) + 1, 1 ),
        d
    )
Measure2 =
VAR d =
    SELECTEDVALUE ( Table1[Date] )
VAR d2 =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    IF (
        d
            >= DATE ( YEAR ( d2 ), MONTH ( d2 ) + 1, 1 )
            && d
                < DATE ( YEAR ( d2 ), MONTH ( d2 ) + 2, 1 ),
        d
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors