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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Pker_Tank
Regular Visitor

If a Date is selected I need to get the Last 14 days data.

Hi, 
I am stuck with this use case, and need your assistance. 
If a user selects a date ending from the date filter (ex: 14 Dec) he should see the data from 1st Dec to 14th Dec.
I have a date table mapped to Actual tables date column.
So the filter will be using the date table, Date column.
In the table view, I will be using Date column of my actual table.
Hope it makes sense. Pleaselet me know if more information needed. Thanks heaps guys

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Pker_Tank 

 

Thanks for the reply from Jihwan_Kim .

 

Pker_Tank, please refer to the following test.

 

Sample:

vxuxinyimsft_0-1735627240404.png

 

vxuxinyimsft_1-1735627287393.png

 

No relationship between two tables

vxuxinyimsft_2-1735627403006.png

 

Create a measure as follows

Measure = 
VAR _selected = SELECTEDVALUE('Date'[Transdate])
RETURN
IF(_selected = BLANK(), 1, IF(MAX([Transdate]) >= _selected - 13 && MAX([Transdate]) <= _selected, 1, 0))

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_3-1735627644449.png

 

Output:

vxuxinyimsft_4-1735627664251.png

 

Best Regards,
Yulia Xu

 

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

6 REPLIES 6
johnt75
Super User
Super User
Poojara_D12
Super User
Super User

Hi @Pker_Tank 

Create a Measure to filter dates from the 1st of the month to the selected date:

 

ShowDates = 
VAR SelectedDate = MAX('DateTable'[Date])
VAR StartOfMonth = DATE(YEAR(SelectedDate), MONTH(SelectedDate), 1)
RETURN
IF(
    MAX('ActualTable'[Date]) >= StartOfMonth &&
    MAX('ActualTable'[Date]) <= SelectedDate,
    1,
    0
)

 

Apply the Measure: Add ShowDates as a visual-level filter and set it to 1.

 

Use a Date Slicer: Add a slicer with the DateTable[Date]. Selecting a date (e.g., 14 Dec) will show rows from 1st Dec to 14th Dec.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Pker_Tank
Regular Visitor

Hi, Sorry I was not clear before.

 

I have a table with columns like ID, NAME, TRANSDATE, CLASS.
I have a Date Table with one Date Column pulling all the dates I needed.
I Mapped the Date Table to My original table with Data column 1 to many mapping.

Now, In my slicer, I am using Date tables, Date column. When I select any date in the slicer, It should automatically filter the last 14 days of dates in my original table

 

For example: This table with dates should appear if I select 14th Dec in my slicer.

IDNameTransdateClass
3sfv1/12/2024a
5bre2/12/2024a
7rgw3/12/2024a
9njyrt4/12/2024a
43shte5/12/2024a
545trh6/12/2024a
757erht7/12/2024a
34thr8/12/2024a
4564terh9/12/2024a
76thr10/12/2024a
43thr11/12/2024a
24rhydt12/12/2024a
57hry13/12/2024a
54657dfbt14/12/2024a
Anonymous
Not applicable

Hi @Pker_Tank 

 

Thanks for the reply from Jihwan_Kim .

 

Pker_Tank, please refer to the following test.

 

Sample:

vxuxinyimsft_0-1735627240404.png

 

vxuxinyimsft_1-1735627287393.png

 

No relationship between two tables

vxuxinyimsft_2-1735627403006.png

 

Create a measure as follows

Measure = 
VAR _selected = SELECTEDVALUE('Date'[Transdate])
RETURN
IF(_selected = BLANK(), 1, IF(MAX([Transdate]) >= _selected - 13 && MAX([Transdate]) <= _selected, 1, 0))

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_3-1735627644449.png

 

Output:

vxuxinyimsft_4-1735627664251.png

 

Best Regards,
Yulia Xu

 

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

Hi,

In my opinion, it still needs disconnected date table and this needs to be used in the slicer visualization.

Thank you for sharing how the expected result looks like, and if it is OK, please share the sample data that you are using behind the result.

It will be helpful if you can share the sample pbix file's link.

Thank you.



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1735482945882.png

 

 

Jihwan_Kim_0-1735482924408.png

 

 

last 14 days sales: =
VAR _dateselect =
    MAX ( slicer_calendar[date] )
RETURN
    CALCULATE (
        SUM ( sales[sales] ),
        KEEPFILTERS ( 'calendar'[date] <= _dateselect ),
        KEEPFILTERS ( 'calendar'[date] >= _dateselect - 13 )
    )

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors