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
Sher
Helper I
Helper I

Dynamic Previous Month Column

Hi,

 

I have included a picture of the table below that I'm working with. Essentialy what I want is a Column that says "TRUE" when it is the previous month dynamically and "FALSE" when it isnt. I can do this through Power Query M, but. for my specific case when the month is January as it is now I want the previous month to be "TRUE" for December. Ignore the date column itself as that doesnt actually matter in this case.Would anyone know how to achieve this dynmaically through DAX?

Sher_1-1610628281010.png

 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @Sher 

 

According to your description,I think you can create a measure or column to calculate the desired result.

Like this:

Column = var month1=MONTH(EDATE(TODAY(),-1))
var month2=MONTH('Table'[date])
return IF(month1=month2,"True","False")
Measure = var month1=MONTH(EDATE(TODAY(),-1))
var month2=MONTH(SELECTEDVALUE('Table'[date]))
return IF(month1=month2,"True","False")

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @Sher 

 

According to your description,I think you can create a measure or column to calculate the desired result.

Like this:

Column = var month1=MONTH(EDATE(TODAY(),-1))
var month2=MONTH('Table'[date])
return IF(month1=month2,"True","False")
Measure = var month1=MONTH(EDATE(TODAY(),-1))
var month2=MONTH(SELECTEDVALUE('Table'[date]))
return IF(month1=month2,"True","False")

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

mahoneypat
Employee
Employee

Here is one way to do it.

 

Prev Month = DATEDIFF ( TODAY (), [Date], MONTH ) = -1
 
Another thing to consider is leaving the "= -1" off and have a column that shows the relative month.  You can filter on =-1 in your measures/visuals, but then you also have the option to make charts/tables using the relative month column.
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


HI Pat,

 

Ive tried this and unfortunately it didnt work, it kept coming up with "BLANK" when i included the =-1 and when i excluded it wasnt of much use unfortunately. have any other ideas or able to help?

 

Thanks 

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.