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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
mariases94
Helper III
Helper III

Previousmonth with Calculate and Userelationship

Hi,

 

I need help with my model. I try to compare the leads we have won this month with the last month. I use the next formula:

 

PrevMonth WIN LEADS = CALCULATE(Opo[Leads ganados], PREVIOUSMONTH(dateadd(Opo[Fecha de cierre real],-1,month)),
USERELATIONSHIP(Opo[Fecha de cierre real],Calendario[Date]))
 
But if I use this formula, it shows me a BLANK.
 
Where is the mistake? Is in the formula? Maybe in the relationships?
 
Thanks for the help.
 
 
1 ACCEPTED SOLUTION

 

 

 

PREVIOUSMONTH(dateadd(Opo[Fecha de cierre real],-1,month))

 

 

 

means "go back one month and then take ALL DATES from the month before"

use 

 

 

 

PREVIOUSMONTH(Opo[Fecha de cierre real])

 

 

 

instead if you want ALL DATES from the previous month,

or 

 

dateadd(Opo[Fecha de cierre real],-1,month)

 

if you want to shift all the dates by a month into the past.

Power BI DAX: DATEADD versus PREVIOUSMONTH – Minova

View solution in original post

6 REPLIES 6
ryan_mayu
Super User
Super User

@mariases94 

https://docs.microsoft.com/en-us/dax/previousmonth-function-dax

https://docs.microsoft.com/en-us/dax/dateadd-function-dax

use either previousmonth or dateadd.  





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu,

 

I use the two formulas, but it return me blanks again...how can I solve it?

@mariases94 

what's the formula you are using now?

maybe you can try

PrevMonth WIN LEADS = CALCULATE(Opo[Leads ganados],dateadd(Calendario[Date],-1,month),

USERELATIONSHIP(Opo[Fecha de cierre real],Calendario[Date]))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




 

 

 

PREVIOUSMONTH(dateadd(Opo[Fecha de cierre real],-1,month))

 

 

 

means "go back one month and then take ALL DATES from the month before"

use 

 

 

 

PREVIOUSMONTH(Opo[Fecha de cierre real])

 

 

 

instead if you want ALL DATES from the previous month,

or 

 

dateadd(Opo[Fecha de cierre real],-1,month)

 

if you want to shift all the dates by a month into the past.

Power BI DAX: DATEADD versus PREVIOUSMONTH – Minova

lbendlin
Super User
Super User

You are basically applying Previous month twice.  What made you choose USERELATIONSHIP?  It is not required here.

Hi @lbendlin,

 

I can't saw where I use two times "previousmonth".

 

I have 5 date columns in the principal table, so I made 5 relations between de column "date" of the calendar table with each column type date of the principal table. I use USERELATIONSHIP because I have to use the relation with the other date column. For example, if I want to use "fecha alta" I use USERELATIONSHIP to switch the relation. Because I don't know how to pick another column type date if I don't use USERELATIONSHIP...

 

mariases94_0-1627633394475.png

 

 

**I have to say that I use PBI since may and I'm noobie with it and there are some things that I don't understand at all.

 

Thanks,

 

Maria.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors