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
snandy2011
Helper IV
Helper IV

how to show same period last month by weekday

Hi,

 

I want to compare same period last month data by weekday. I have monthly and daily distribution data. So if i select any month, it is showing day wise data according to this month. now, i want to compare may with previous month. so, for that i have written following formula,

 

Same Period Last Month = CALCULATE(SUM('All Web Site Data'[New Users]), DATEADD('Date Table'[Date],-1,MONTH) )

 

if i want to compare monthly total of selected month and its previous month, then it showing the correct figure. But, the problem arise when i use this measure for comparing the day wise total of selected month and it's previous month. Suppose, I have selected May. So the previous month April's day wise data are

 

Day     Total

Mon    662

Tues    936

Wed     687

Thurs    694

Fri         633

Sat        495

Sun       489

 

But, when i use that above formula "Same period Last month" with week day name it showing wrong figure, instead of showing above April's daily data.

 

Please see  the below screenshots for better understand.

 

April's Day wise DataApril's Day wise DataCompare May's Data with AprilCompare May's Data with April

 

 

 

 

it seems that my "Same period last month" formula is not working with day name. I have written another formula, which is like that,

 

same period last month 2 = CALCULATE('All Web Site Data'[Total new user],PREVIOUSMONTH('Date Table'[Date]))

 

but, did not workout.

 

can you please identify why it is not working.

 

Any suggestion and advice is really appreciable.

 

Thanks,

snandy2011

5 REPLIES 5
Anonymous
Not applicable

Same Period Last Month =
CALCULATE (
    SUM ( 'All Web Site Data'[New Users] ),
    MONTH('Date Table'[Date]) = MONTH(DATEADD ( 'Date Table'[Date], -1, MONTH ))
)

hi @Anonymous,

 

Thanks for your reply. But, your formula is not working.It is showing the following error,

 

"A function 'DATEADD' has been used in a True/False expression that is used as a table filter expression. This is not allowed.".

 

I did a little tweak, put the filter function on that. But it shows nothing,

 

CALCULATE (
SUM ( 'All Web Site Data'[New Users] ),FILTER('Date Table',
MONTH('Date Table'[Date]) = MONTH(DATEADD ( 'Date Table'[Date], -1, MONTH ))
) )

 

Do you have any other idea regarding that?

 

 

Anonymous
Not applicable

Maybe try loading your last month value in to a car, something like below, not sure on the content of your date table but a variation of the below measure should work. Apologies I'm not at my computer right now so doing this on a phone.

Same Period Last Month =
Var LastMonth = Month(selectedvalue('Date Table'[Month])) -1
Return
CALCULATE (
SUM ( 'All Web Site Data'[New Users] ),
MONTH('Date Table'[Date]) = LastMonth
)

Sorry sir, 

 

It not working again.. It ahowing the error of 

"cannot convert value month of type to type text"

 

I have used 'date table'[month name] instead of [Month]. Because I have column in date table named moth name.

 

I also tried with date value function instead of selected value.. But it shows nothing.

 

It's ok.. I am going through with your solution. If it does not works. I will let you know..

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.