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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pmadam
Helper II
Helper II

DAX Help

Hi Team,

 

If someone can can help me with below issue.

 

I am trying to Calculate Previos Quarter , Previous Month. Issue is for Previous Quater, Prev Month it should give me 2022 Q4 values but with below dax, its not understanding to go to previous year

 

Below DAX works from Feb to Dec and doesnt work for Jan , as it doesnt understand to go to 2022 Dec month

 

Prev_Month = MONTH(TODAY())-1
PMonth Book = CALCULATE(SUM('YTD Total'[Book RR]), FILTER('YTD Total','YTD Total'[Month Number]= [Prev_Month]))
 
Now, Im not sure how to even start writing DAX for Previous Quarter.
 
Please help.
 
Thanks,
PV
2 REPLIES 2
FreemanZ
Super User
Super User

hi @pmadam

try to join your table with a qualified date table and utilize Time Intelligence Functions like DATEADD
for previous month,
CALCULATE(
...,
DATEADD(DateTable[Date], -1, MONTH)
)
for previous quarter, DATEADD(DateTable[Date], -3, MONTH)

But this works only when there is some  Year or Quarter selection in slicers. But i want without any selections of slicers from date. 

 

I get "dateadd expects a contiguous selection" error msg if i do not make any date selections or add Year ot Quarter to the table. And i have one - many directional tables.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors