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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
game1
Helper III
Helper III

Filter last 7 days and 60 days of selected range calendar

Hello, 

I have Table1[dateExam] and Table1[numberPeople].

First, I need to use a CALENDAR (range slicer) to select a date (it must only consider the max date of range slicer selected). For example, I can select 10/01/2021 as my maximum date.

Second, I need to check one of the options: (in Segment). For example, I can check the option “last 7 days”.

Then, it would return me the numberPeople for the “last 7 days” of the selected date in the CALENDAR.(So the “last 7 days” is base on the CALENDAR (range slicer) I have selected.)

In other words, it would return me in a graphic, the numberPeople between 03/01/2021 and 10/01/2021.

For this example, in a graphic, I would have for each day between 03/01/2021 and 10/01/2021, the numberPeople that have done dateExam from Table1[dateExam].

Capture d’écran, le 2024-01-14 à 03.04.23.pngCapture d’écran, le 2024-01-14 à 03.04.46.png

Thanks!

10 REPLIES 10
LufengYuan
Frequent Visitor

Hello 
You may try to use a field parameter as the segment slicer that consist of the measures like 'last7days','last10days'.
I created the following measure and seems works. Hope this helpful for you.

([Total People]  just a sum of Table1[numberPeople])

last 7 Days =
var _maxDate = MAX(Table1[dateExam])
var _result =
CALCULATE(
    [Total People],
    'Table1'[dateExam] > _maxDate - 7 &&
    'Table1'[dateExam] <= _maxDate

)
RETURN _result
 
LufengYuan_0-1705368895342.png

 

Hello, 

How did you apply the relation beetween the table Date(slicer) and Table1 ?

Thanks for your help! 

Also, what kind of relation or cardinality did you apply to the table?

Can you post the screen shot or the file? 

Thanks!

Hello,
Yes, I think this is close to what I want, but for your example, I see that the LAST 7 DAYS option, didn't really apply. This should be between 01/19/2020 to 01/25/2020 right (the column dateExam)?

Thanks!

I think the last 7 days apply to the result as 126 = 15+16+...+21 . Here is the relationship, hope it is helpful for you. Sorry for the late reply as so busy on my job.

LufengYuan_0-1705707225277.png

 

Ok! But how do you do that the slicer 'Date' be functionning? 

Thanks!

 

Anonymous
Not applicable

HI @game1,

I'd like to suggest you take a look at the following blog about create segmentation table. You can use the segment field as source of slicer to filter your table records.

Static segmentation – DAX Patterns

Regards,

Xiaoxin Sheng

game1
Helper III
Helper III

Ok! But if I do CALENDAR as list check, like the option slicer? 

Anonymous
Not applicable

Hi @game1,

AFAIK, the default filter effects not able to achieve your requirement.

For this scenario, I'd like to suggest you create an unconnected table source of slicer. Then you can write a measure formula to receive the filter effect and use on visual to achieve filter effects.
Regards,

Xiaoxin Sheng

Ok! But if I do CALENDAR as list check, like the option slicer? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.