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
rj1120
Frequent Visitor

Automation by using Date filters

Hello Everyone,

 

I'm new to Power BI.I have some issue with date filters.Please help me..

 

I have one excel transfermation file.In this few sheets are there.By using these sheets,I'm creating different roports for last 4 weeeks and current week in the same dashboard.

 

For automation purpose,I'm using Edit Query in Power BI Desktop.In the power query I'm using date filters.When I apply filter for current week it will be applicable for last 4 weeks report also and vice versa  because I'm using same data for both reports.

 

How can I apply filters for the two reports seperately ??

 

Can any one give some solution for this.Thanks in advance.. 

1 ACCEPTED SOLUTION

@rj1120

 

In this scenario, I think you can create another two calculate tables, one only includes data for current week and another one only includes data for last four weeks. Below is a simple sample, hope it helps.

 

Assume that we have a simple table which includes all data from 5/1/2016 to 8/5/2016 as below. We can create a new WEEKNUM column with following formula.

WeekNum = WEEKNUM ( Table1[Date] )

Automation by using Date filters_1.jpg

 

Then we can use following formulas to create another two tables.

CurrentWeek = 
CALCULATETABLE (
    Table1,
    FILTER ( Table1, Table1[WeekNum] = MAX ( Table1[WeekNum] ) )
)

Automation by using Date filters_2.jpg

 

LastFourWeeks = 
CALCULATETABLE (
    Table1,
    FILTER (
        Table1,
        Table1[WeekNum] < MAX ( Table1[WeekNum] )
            && Table1[WeekNum]
                >= ( MAX ( Table1[WeekNum] ) - 4 )
    )
)

Now we can drag data from above two tables for the corresponding report. I’ve uploaded this Power BI file here in case you need it.

Automation by using Date filters_3.jpg

 

Best Regards,

Herbert

View solution in original post

5 REPLIES 5
ankitpatira
Community Champion
Community Champion

@rj1120 I am guessing you have 4 reports on 4 seperate pages. You can choose between page level filters and report level filters. Page level filters will apply to all visuals on that page only and report level will apply to all pages. That would be an easy way to apply filter to certain visuals or just one page.

Hi Ankit,

 

Thanks for the sugesstion.

 

But i dont want to do that because with your solution if next time new week data comes and if refereshes the reports then i have to change the filters as well manually.

 

I just want to avoid manual work and automatically my reports should show four week and current week data based on date filter.

 

Please let me know if i am understanding anything wrong here. I suppose it should work like this.

 

Thanks 

Rajendra

@rj1120

 

In this scenario, I think you can create another two calculate tables, one only includes data for current week and another one only includes data for last four weeks. Below is a simple sample, hope it helps.

 

Assume that we have a simple table which includes all data from 5/1/2016 to 8/5/2016 as below. We can create a new WEEKNUM column with following formula.

WeekNum = WEEKNUM ( Table1[Date] )

Automation by using Date filters_1.jpg

 

Then we can use following formulas to create another two tables.

CurrentWeek = 
CALCULATETABLE (
    Table1,
    FILTER ( Table1, Table1[WeekNum] = MAX ( Table1[WeekNum] ) )
)

Automation by using Date filters_2.jpg

 

LastFourWeeks = 
CALCULATETABLE (
    Table1,
    FILTER (
        Table1,
        Table1[WeekNum] < MAX ( Table1[WeekNum] )
            && Table1[WeekNum]
                >= ( MAX ( Table1[WeekNum] ) - 4 )
    )
)

Now we can drag data from above two tables for the corresponding report. I’ve uploaded this Power BI file here in case you need it.

Automation by using Date filters_3.jpg

 

Best Regards,

Herbert

For automation purpose,I'm using Edit Query in Power BI Desktop.In the power query I'm using date filters.When I apply filter for current week report it will be applicable for last 4 weeks report also and vice versa  because I'm using same data for both reports.

 

How can I apply filters for the two reports seperately where data comes from the same sheet/workbook/table??

Automation using edit query Data filters.pngBelow is my screenshot.

My Query is somehow if we can apply automated filters to each report.

 

samdthompson
Memorable Member
Memorable Member

Hi, can you post some screen shots of the data?

// if this is a solution please mark as such. Kudos always appreciated.

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.