cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Frequent Visitor

## Show previous period on selecting the current period using date slicer

I want to Calculate a Metric for a Previous Period based on the Current Selected Period.

For example: If the user selected a date range of the last 7 days, I want to calculate a Metric for the 7 days before that. It should be dynamic based on the user selection of the date range, not a fixed number.

The end goal is to calculate the percentage of change between the 2 values (Metric in the current selected date range and the previous date range).

The output should be a single numeric value.

For example:

Current period order count: 100
Previous period order count: 150

1 ACCEPTED SOLUTION
Super User

Hi @Zain_
what answer you are getting after applying above Dax??

why you have two calendar ??

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
4 REPLIES 4
Super User

Hi @Zain_
try below dax

``````Previous Period  =
VAR __StartDate = CALCULATE ( MIN ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )
VAR __EndDate = CALCULATE ( MAX ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )
VAR __Days = DATEDIFF ( __EndDate, __StartDate, DAY ) - 1
RETURN
CALCULATE ( [Order count], DATEADD ( Dates[Date], __Days, DAY ) )``````

I hope this would get the correct previous period values.

Then you can later divide this by using formla
%change= Divide( [Order count], [Previous Period],0)

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Frequent Visitor

Not Working. This is my DAX formula:

Previous Period =
VAR __StartDate = CALCULATE ( MIN ('Calendar'[Date]), ALLSELECTED ( 'Calendar'[Date]) )
VAR __EndDate = CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date]) )
VAR __Days = DATEDIFF ( __EndDate, __StartDate, DAY ) - 1
RETURN
CALCULATE ( [ACount_Sub], DATEADD ( 'Calendar'[Date], __Days, DAY ) )

I have 2 calendar tables 1 calendar is connected to other visual and how can i connect the other calendar?

I want to make this type of table

Super User

Hi @Zain_
what answer you are getting after applying above Dax??

why you have two calendar ??

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Frequent Visitor

one is for another visual and 2nd calendar is for the visual which I'm trying to create

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors