Deep21
Frequent Visitor

Calculating previous quarter Actual data based on the year and month slicer selection

I implemented this for current month calculation

CQ value =

CALCULATE(SUM('CRAFData'[Actual]),FILTER(ALL('Date_Com'),'Date_Com'[QuarterNo]=ROUNDUP(SELECTEDVALUE('Date_Com'[MonthNo])/3,0))) ,

and it worked fine .

However same i would like to implement for previous month , can anyone let me know how to use DAX formula for the same . Currently i am using ,

PQ value = CALCULATE(SUM('CRAFData'[Actual]),FILTER(ALL('Date_Com'),'Date_Com'[QuarterNo]=ROUNDUP(SELECTEDVALUE('Date_Com'[MonthNo])/3,0)-1)) This is not working correctly for first three months(quarter 1) selected for the current year.

 

I was even trying some if conditions , but seems it is also having error in concadination.

 

PQ value =
VAR v =ROUNDUP(SELECTEDVALUE('Date_Com'[MonthNo])/3,0)-1
Var q1CALCULATE(SUM('CRAF Data'[Actual]),FILTER(ALL('Date_Com'),CONCATENATEX(Date_Com,'Date_Com'[Year]=(SELECTEDVALUE(Date_Com[Year])-1),Date_Com[QuarterNo]="4")))
var q2CALCULATE(SUM('CRAF Data'[Actual]),FILTER(ALL('Date_Com'),'Date_Com'[QuarterNo]=ROUNDUP(SELECTEDVALUE('Date_Com'[MonthNo])/3,0)-1 ))
VAR A = IF(v=0 ,q1,q2return A

 

Any leads will help .