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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Show Data in frequency of 30 days

Hi All,

 

In my report i have a refresh date column which will have list of dates at which refresh happened. initially i want to show data for only latest 30 days to user. foe ex- if latest refresh date is 12/05/2020, data should be from 12/04/2020 to 12/05/2020. 

 

I will have this refresh date column as slicer . whenever user clicks on particular date in this slicer, i should get data for 30 days from date of selection(if user clicks feb15, data should be from feb15-Mar14) and in other slicer i should get only dates between selected date and 30 days date(feb15-mar14 dates)( This slicer is for if user want to see single day data).

 

Please help me to solve this.

TIA

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

@Anonymous 

 

Based on your description, I created data to reproduce your scenario.

Table:

a1.png

 

DateTable:

 

DateTable = DISTINCT('Table'[Refresh Date])

 

 

You may create two measures as below.

 

Isdisplay = 
var _date = SELECTEDVALUE('Table'[Refresh Date])
var _latestdate = 
CALCULATE(
    MAX('Table'[Refresh Date]),
    ALL('Table')
)
return
IF(
    DATEDIFF(_date,_latestdate,DAY)<=31,
    1,
    0
)

Visual control = 
var _selecteddate = SELECTEDVALUE(DateTable[Refresh Date])
var _refreshdate = SELECTEDVALUE('Table'[Refresh Date])
return
IF(
    ISFILTERED(DateTable[Refresh Date]),
    IF(
        DATEDIFF(_selecteddate,_refreshdate,DAY)<=31&&
        DATEDIFF(_selecteddate,_refreshdate,DAY)>0,
        1,
        0
    ),
    1
)

 

 

You need to put the measure in the visual level filter to display the result. 'Isdisplay' measure is to show data for only latest 30 days. 'Visual control' is to get data for 30 days from date of selection. Then you may use the 'Refresh Date' from DateTable to filter the visual with 'Visual Control'.

 

Result:

a2.png

a3.png

 

Best Regards

Allan

 

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

5 REPLIES 5
v-alq-msft
Community Support
Community Support

@Anonymous 

 

Based on your description, I created data to reproduce your scenario.

Table:

a1.png

 

DateTable:

 

DateTable = DISTINCT('Table'[Refresh Date])

 

 

You may create two measures as below.

 

Isdisplay = 
var _date = SELECTEDVALUE('Table'[Refresh Date])
var _latestdate = 
CALCULATE(
    MAX('Table'[Refresh Date]),
    ALL('Table')
)
return
IF(
    DATEDIFF(_date,_latestdate,DAY)<=31,
    1,
    0
)

Visual control = 
var _selecteddate = SELECTEDVALUE(DateTable[Refresh Date])
var _refreshdate = SELECTEDVALUE('Table'[Refresh Date])
return
IF(
    ISFILTERED(DateTable[Refresh Date]),
    IF(
        DATEDIFF(_selecteddate,_refreshdate,DAY)<=31&&
        DATEDIFF(_selecteddate,_refreshdate,DAY)>0,
        1,
        0
    ),
    1
)

 

 

You need to put the measure in the visual level filter to display the result. 'Isdisplay' measure is to show data for only latest 30 days. 'Visual control' is to get data for 30 days from date of selection. Then you may use the 'Refresh Date' from DateTable to filter the visual with 'Visual Control'.

 

Result:

a2.png

a3.png

 

Best Regards

Allan

 

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

 

Greg_Deckler
Super User
Super User

Here is another example (attached)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

 Can you please explain what your logic is doing here. I mean how your power BI file explains my requirment

Your requirement is that you need to display certain information in a visualization based upon a complex selection criteria. That is what those two PBIX files do. If you want something very specific to your situation, please provide sample data and expected output.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

You would need something like a Complex Selector. See attached. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.