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
Anonymous
Not applicable

I want to display the previous month and year with conditions

The following command works fine while adding a new column

 

 

FORMAT(EOMONTH(DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW())),-1), "MMMM-YYYY")

 

 

But when I try to use it like this 

 

 

Check Empty = 
IF(ISBLANK('August''2020'[LSA]),(IF(ISBLANK('August''2020'[Description of the Change]),"*For the month of "& (FORMAT(EOMONTH(DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW())),-1), "MMMM-YYYY"))  & ", there were no compliant based Cos."), " "))

 

 

It displays 

 

 

Operator or expression '( )' is not supported in this context.

 

 

What's happeing? And how to remove this?

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , You can use date table and time intelligence

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

View solution in original post

AllisonKennedy
Super User
Super User

You have a syntax error in it. Daxformatter.com is a great site for formatting your code: 

 

AllisonKennedy_0-1604920942716.png

Not sure if this is what you're looking for: 

 

Check Empty =
IF (
    ISBLANK ( 'August''2020'[LSA] ),
    IF (
        ISBLANK ( 'August''2020'[Description of the Change] ),
        "*For the month of "
            FORMAT (
                EOMONTH ( DATE ( YEAR ( NOW () )MONTH ( NOW () )DAY ( NOW () ) )-1 ),
                "MMMM-YYYY"
            ) & ", there were no compliant based Cos."
    ),
    " "
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
AllisonKennedy
Super User
Super User

@Anonymous yes, I think there was a missing bracket near the end, though I also removed some of the extra brackets that were unnecessary 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

You have a syntax error in it. Daxformatter.com is a great site for formatting your code: 

 

AllisonKennedy_0-1604920942716.png

Not sure if this is what you're looking for: 

 

Check Empty =
IF (
    ISBLANK ( 'August''2020'[LSA] ),
    IF (
        ISBLANK ( 'August''2020'[Description of the Change] ),
        "*For the month of "
            FORMAT (
                EOMONTH ( DATE ( YEAR ( NOW () )MONTH ( NOW () )DAY ( NOW () ) )-1 ),
                "MMMM-YYYY"
            ) & ", there were no compliant based Cos."
    ),
    " "
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy 
Thanks for the help and providing such a great resource(DAX Formatter). I think I was missing a bracket, right?
Stay Awesome.

amitchandak
Super User
Super User

@Anonymous , You can use date table and time intelligence

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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.