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
Roseventura
Responsive Resident
Responsive Resident

DATEADD not calculating correct totals

I've seen this work in other people's examples, but I can never get it to work in mine.

 

My DATEADD() measure is not calculating the correct totals for the previous month or previous quarter.  Here are my measures:

 

     Sales LM = calculate ( [Total Sales] , dateadd( PBI_FSCAPF[PADDATE], -1, MONTH ))
 
          and
 
     Sales LQ = calculate ( [Total Sales] , dateadd( PBI_FSCAPF[PADDATE], -1, QUARTER ))
 
PBI_FSCAPF is my date table and PADDATE is my date field formatted as mm/dd/yyyy.  YEAR-MO and YEAR-QTR are also in the date table.
 
 
Capture17.JPG
 
Has anyone ever seen this before?
 
Thanks,
Rose
 

 

1 ACCEPTED SOLUTION

Ashish,

 

Your measure came close, but not every previous month was accurate.  I found a you-tube video that demonstrated how to calculate the previous month's sales and that worked perfectly. 

 

When you have custom calendars like mine, normal time intelligence functions don't work.  Here is my measure:

 

Prev Month Sales =
     var CurrentMonth = SELECTEDVALUE( PBI_FSCAPF[CAFMON] )
     var CurrentYear = SELECTEDVALUE( PBI_FSCAPF[PADFYR] )
     var MaxMonthNum = CALCULATE( MAX( PBI_FSCAPF[CAFMON] ) , ALL(PBI_FSCAPF) )
RETURN
IF( HASONEVALUE( PBI_FSCAPF[CAFMON] ) ,
     SUMX(
          FILTER ( ALL (PBI_FSCAPF),
               IF ( CurrentMonth = 1,
                    PBI_FSCAPF[CAFMON] = MaxMonthNum && PBI_FSCAPF[PADFYR] = CurrentYear - 1,
                    PBI_FSCAPF[CAFMON] = CurrentMonth -1 && PBI_FSCAPF[PADFYR] = CurrentYear ) ),
              [Total Sales] ),
     BLANK() )
 
Credit goes to Sam McKay of Enterprise DNA.

View solution in original post

12 REPLIES 12

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.