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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Users online (472)