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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Show days before the selected date

Hey guys, I am basically trying to get the calculations so that once the date is chosen in the filter, I could show particular number of days back. This is the idea I got from this guy : https://www.youtube.com/watch?v=MooZofz5GOI 
The only thing I dont get is how can I do the number of days measure such that when u put it in the measure, it would actually acount the days and would let you choose number of days like in the picture: 

Gediminas12_0-1610554523002.png

 


https://www.youtube.com/watch?v=MooZofz5GOI

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

To achieve the simliar result from the viedo, you need to create what-if parameter first:

parameTer.png

It will produce a table with a column, a measure and a slicer which includes the column, just rename them to show the number:

number.png

Then you need a separate date table and use it as another slicer, if your source table has already had date columns, you can use CALENDARAUTO(), DISTINCT() to create it.

Create a Date selected measure:

Date selected = SELECTEDVALUE('Date'[Date])

Create a total measure like this and put it in the bar chart:

Total =
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Date] <= SELECTEDVALUE ( 'Date'[Date] )
            && 'Table'[Date]
                >= SELECTEDVALUE ( 'Date'[Date] ) - [Day Number]
    )
)

1.png2.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
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

7 REPLIES 7
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

To achieve the simliar result from the viedo, you need to create what-if parameter first:

parameTer.png

It will produce a table with a column, a measure and a slicer which includes the column, just rename them to show the number:

number.png

Then you need a separate date table and use it as another slicer, if your source table has already had date columns, you can use CALENDARAUTO(), DISTINCT() to create it.

Create a Date selected measure:

Date selected = SELECTEDVALUE('Date'[Date])

Create a total measure like this and put it in the bar chart:

Total =
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Date] <= SELECTEDVALUE ( 'Date'[Date] )
            && 'Table'[Date]
                >= SELECTEDVALUE ( 'Date'[Date] ) - [Day Number]
    )
)

1.png2.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@v-yingjlDude thats sick, thank you so much. Also wondering if you will know this : 
In one of the report pages I always display data of the current month up to to day, any idea how can I make it that the last day chosen in the filter would give all the days up to date?

Hi @Anonymous ,

You can use CALENDAR() to modify your date table, use Today() as the ending date parameter:

Table 2 = CALENDAR("2021/1/1",TODAY())

So that each time you open the report, the last date in the slicer will be the latest day.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Dude I can't thank you enough. Thank you so much !!

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Have you looked into what-if parameters in power BI? These allow user to select a custom value and use it in the calculations.

Check following article for same:

https://radacad.com/power-bi-what-if-parameters

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

@Pragati11 Hi, thanks for sharing it, seems very interesting, just the question what can I make of this for my issue? would u miind elaborating a bit?

Hi @Anonymous ,

 

Apologies I think I mis-understood your query. Is it possible for you to add more description by showing some sample data rows and what is the expected calculation output?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.