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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sreddy47652
Helper III
Helper III

Based on slicer selection need to display previous quarter

Hi Team, i need to some help on below dax based on slicer selection when  we go for q2 i need to show previous quarter value, if i go Q3 need to display Q2 value. I tried based on my requirement on below formula but it's giving wrong result. can anyone correct my formula.

Result need to display like this

sreddy47652_0-1725963314626.png

My Formula is

QTY Orderr-REQ-Fcst Selected Cycle_lookup =

VAR MINDATE =
CALCULATE(
MIN(Calender_Cycle_dt[Date]),
ALLSELECTED(Calender_Cycle_dt[Date])
)


VAR MNTHNO = MONTH(MINDATE)-3
VAR YRNO = YEAR(MINDATE)
VAR PREVIOUSDATE = DATE(YRNO,MNTHNO,01)
/*IF((MNTHNO) = -1,DATE((YRNO-1),12,DAY(MINDATE)),
DATE(YRNO,MNTHNO,DAY(MINDATE)))*/

///TYPE_1 CALC >> GET ALL MAF

VAR TYPE1 =
CALCULATE(
[p.forcast_summarize_data] ,
ALL(GlobalForecast_DQ[CYCLE_DT]),
FILTER(GlobalForecast_DQ,(GlobalForecast_DQ[PERIOD_DT]) >= PREVIOUSDATE &&
GlobalForecast_DQ[CYCLE_DT] = PREVIOUSDATE))


VAR TYPE3 =
CALCULATE(
Sum(GlobalForecast_DQ[REQ]),
ALL(GlobalForecast_DQ[CYCLE_DT]),
FILTER(GlobalForecast_DQ,(GlobalForecast_DQ[PERIOD_DT]) < PREVIOUSDATE &&
GlobalForecast_DQ[CYCLE_DT] = DATE(5999,01,01)
) )

/// >>FINAL RESULT BASED ON MONTH SELECTION

RETURN
TYPE1 + TYPE3

1 ACCEPTED SOLUTION
Joe_Barry
Super User
Super User

Hi @sreddy47652 

 

Are you using a Calendar table in your model?

If so you can do the following by creatinga QTD mesure

Forecast QTD =
TOTALQTD(Sum(GlobalForecast_DQ[REQ), 'Calendar[Date])


Then you can use this measure to calculate the previous quarter

Forecast PQ = 
CALCULATE( [Forecast QTD], DATEADD('Calendar'[Date], -1, QUARTER))

Hope this helps
Joe

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


View solution in original post

1 REPLY 1
Joe_Barry
Super User
Super User

Hi @sreddy47652 

 

Are you using a Calendar table in your model?

If so you can do the following by creatinga QTD mesure

Forecast QTD =
TOTALQTD(Sum(GlobalForecast_DQ[REQ), 'Calendar[Date])


Then you can use this measure to calculate the previous quarter

Forecast PQ = 
CALCULATE( [Forecast QTD], DATEADD('Calendar'[Date], -1, QUARTER))

Hope this helps
Joe

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


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.

Top Solution Authors