cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
banthorpe Regular Visitor
Regular Visitor

Error with PREVIOUSMONTH - duplicatedates

HI - I am trying to build a new measure which returns the calculated value for the previous month.

 

This is the initial measure I am working with which returns the correct data:

 

MeetingsPerDay = DIVIDE(COUNTROWS(MeetingsDashboard),DISTINCTCOUNT(MeetingsDashboard[localStartDate].[Day]))

 

I then tried to create a new measure to calculate the answer for the previous month as follows:

 

MeetingsPerDayLastMonth = CALCULATE(DIVIDE(COUNTROWS(MeetingsDashboard),DISTINCTCOUNT(MeetingsDashboard[localStartDate].[Day])),PREVIOUSMONTH(MeetingsDashboard[localStartDate]))

 

but it returns a DAX error:

 

Calculation error in measure 'MeetingsDashboard'[MeetingsPerDayLastMonth]: A date column containing duplicate dates was specified in the call to function 'PREVIOUSMONTH'. This is not supported.

 

any suggestions please!

 

I need this so I can build up a KPI visual comparing this month to last month etc.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Interkoubess Established Member
Established Member

Re: Error with PREVIOUSMONTH - duplicatedates

HI @banthorpe,

 

Please create a Calendar table covering your period ( for example 2 years ..) and link this table to your fact table by the date.

 

Then you can write your measure with the previousmonth function and calendar date.

 

Hope it helps otherwise give sample data and will help.

 

Ninter.

4 REPLIES 4
Interkoubess Established Member
Established Member

Re: Error with PREVIOUSMONTH - duplicatedates

HI @banthorpe,

 

Please create a Calendar table covering your period ( for example 2 years ..) and link this table to your fact table by the date.

 

Then you can write your measure with the previousmonth function and calendar date.

 

Hope it helps otherwise give sample data and will help.

 

Ninter.

banthorpe Regular Visitor
Regular Visitor

Re: Error with PREVIOUSMONTH - duplicatedates

What do you mean by link the table?

v-jiascu-msft Super Contributor
Super Contributor

Re: Error with PREVIOUSMONTH - duplicatedates

Hi @banthorpe,

 

It's the new date table. We usually create an independent date table in your scenario. Please give it a try. 

Calendar = calendar(date(2017,1,1),date(2018,12,31))
Calendar = calendarauto()

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
v-jiascu-msft Super Contributor
Super Contributor

Re: Error with PREVIOUSMONTH - duplicatedates

Hi @banthorpe,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
GregDeckler

How to Get Your Question Answered Quickly

Power BI Super User, Greg Deckler, explains

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Users Online
Currently online: 42 members 1,098 guests
Please welcome our newest community members: