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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
yolandacb
Helper I
Helper I

add a column that puts PM whenever power bi finds that the date is the previous month just gone

I am trying to add a column that put PM whenever power bi finds that the date is the previous month just gone.
 
Is PM =
IF (
'Append'[Previous Month] = PREVIOUSMONTH(FinDate[Date]),
"PM",
"NO"
)
 
I get no syntax errors, but when i run it I get this error:
 
The name 'IF' wasn't recognized. Make sure it's spelled correctly
 
Please can you help?
1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @yolandacb  Try below code to create a calculated column:

Is PM = 
IF (
    MONTH('Append'[Date]) = MONTH(TODAY()) - 1 &&
    YEAR('Append'[Date]) = YEAR(TODAY()),
    "PM",
    "NO"
)

 

Output:

shafiz_p_0-1732188626808.png

 

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

7 REPLIES 7
FreemanZ
Super User
Super User

hi @yolandacb ,

 

you can also try like:

Is PM = 

IF (

    EOMONTH('Append'[Date], 0) = EOMONTH(TODAY(), -1),

    "PM",

    "NO"

)

saurabhtd
Resolver II
Resolver II

@yolandacb You are unable to find  'Append'[Previous Month] beacuse Append and FinDate are two different tables which might not have relationship between them. 

Alternatively if you wan create a column to decide Is PM you can try below code it calculates based on 'FinDate'[Date]

IsPM = 
IF (
    'FinDate'[Date] >= EOMONTH(TODAY(), -2) + 1 &&
    'FinDate'[Date] <= EOMONTH(TODAY(), -1),
    "PM",
    "NO"
)

 

For some reason this didn't work. I get this error:

 

A single value for column 'Date' in table 'FinDate' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

Can you help?

shafiz_p
Super User
Super User

Hi @yolandacb  Try below code to create a calculated column:

Is PM = 
IF (
    MONTH('Append'[Date]) = MONTH(TODAY()) - 1 &&
    YEAR('Append'[Date]) = YEAR(TODAY()),
    "PM",
    "NO"
)

 

Output:

shafiz_p_0-1732188626808.png

 

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Thank you. When I try to use your suggested code, I can't find the column (it doesn't show). Only measures are suggested.

That was a example. You need to use your date column.

Sorry, I was creating a measure rather than a column. When I went to create a column it worked. THank you

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.