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
Bhanuaripaka
Frequent Visitor

Immediately Prior focus period measure

Hi all, 

I am trying create a sum of sales prior period dax measure based on current slicer date range selction. 

for eg:  my Slicer date range is April 20 -  7 may, days between this date range is 17 , I want a measure which goes 17 days behind from start date (April 20 ). I.e; April 3rd to 19 April 

it should display some thing like this 

Bhanuaripaka_0-1716188067733.png

 

Really appreiate your help. Thank you! 

3 ACCEPTED SOLUTIONS
xifeng_L
Super User
Super User

Hi @Bhanuaripaka ,

 

You can refer to below demo.

 

xifeng_L_0-1716190240278.png

 

Demo - Immediately Prior focus period measure.pbix

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

View solution in original post

@Bhanuaripaka 

 

You can refer to below measure.

 

xifeng_L_0-1716539782069.png

 

Measure = 
VAR CurDate = MAX('Date'[Date])
VAR Slicer_Start = CALCULATE(MIN('Date'[Date]),ALLSELECTED())
VAR Slicer_End = CALCULATE(MAX('Date'[Date]),ALLSELECTED())
VAR N = Slicer_End-Slicer_Start
RETURN
CALCULATE(
    SUM('Sales'[Quantity]),
    'Date'[Date]=CurDate-N-1
)

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

View solution in original post

@Bhanuaripaka 

 

You can refer to it.

 

Measure = 
VAR Slicer_Start = CALCULATE(MIN('Date'[Date]),ALLSELECTED())
VAR Slicer_End = CALCULATE(MAX('Date'[Date]),ALLSELECTED())
VAR N = Slicer_End-Slicer_Start
RETURN
SUMX(
    VALUES('Date'[Date]),    // Use the Row label Field of Matrix
    VAR CurDate = 'Date'[Date]
    RETURN
    CALCULATE(
        SUM('Sales'[Quantity]),
        'Date'[Date]=CurDate-N-1,
        ALL ('Time Granularity Table')
    )
)

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

View solution in original post

8 REPLIES 8
xifeng_L
Super User
Super User

Hi @Bhanuaripaka ,

 

You can refer to below demo.

 

xifeng_L_0-1716190240278.png

 

Demo - Immediately Prior focus period measure.pbix

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

Hi. Just wanted to check wheather is there way to build a immediate prior period logic which overlay on current period selection ? 

Currently it shows like this 

Bhanuaripaka_0-1716442722466.png

is there way can we do like below ? 

Bhanuaripaka_1-1716442778874.png

Appreciate your thoughts.

@Bhanuaripaka 

 

You can refer to below measure.

 

xifeng_L_0-1716539782069.png

 

Measure = 
VAR CurDate = MAX('Date'[Date])
VAR Slicer_Start = CALCULATE(MIN('Date'[Date]),ALLSELECTED())
VAR Slicer_End = CALCULATE(MAX('Date'[Date]),ALLSELECTED())
VAR N = Slicer_End-Slicer_Start
RETURN
CALCULATE(
    SUM('Sales'[Quantity]),
    'Date'[Date]=CurDate-N-1
)

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

Hi again. Measure is working exactly as expected but total is incorrect, can you please help me to fix it. Total of Measure should be 563 but it was showing 139.

Bhanuaripaka_2-1716629844078.png

I have tried using SUMX and SUMMARIZE but not luck.

Bhanuaripaka_3-1716629963558.png

 

Thanks for you time.

 

@Bhanuaripaka 

 

You can refer to it.

 

Measure = 
VAR Slicer_Start = CALCULATE(MIN('Date'[Date]),ALLSELECTED())
VAR Slicer_End = CALCULATE(MAX('Date'[Date]),ALLSELECTED())
VAR N = Slicer_End-Slicer_Start
RETURN
SUMX(
    VALUES('Date'[Date]),    // Use the Row label Field of Matrix
    VAR CurDate = 'Date'[Date]
    RETURN
    CALCULATE(
        SUM('Sales'[Quantity]),
        'Date'[Date]=CurDate-N-1,
        ALL ('Time Granularity Table')
    )
)

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

Many thanks again. 

Perfect,Thank you so much.

It worked, thanks much for your help.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.