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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

If function + left and right

Hi all, 

I have the below table and trying to make an end of month formula, but I don't the formula calculates wrong. 

Arsham_0-1600840425560.png

EOM = EOMONTH(IF(AND('Finance Forecast - Test'[FYPeriod]>7, 'Finance Forecast - Test'[FYPeriod]<12) , DATE(RIGHT('Finance Forecast - Test'[FY],4), 'Finance Forecast - Test'[FYPeriod]+6, 1), DATE(2000+LEFT('Finance Forecast - Test'[FY],2), 'Finance Forecast - Test'[FYPeriod]-6, 1)),0)
 
Can any tell me please why the formula doesn't calculate correctly? 
 
Thanks 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

That is the answer of my question for anyone interested in 

EOM = EOMONTH(IF('Finance Forecast - Test'[FYPeriod]<=6, DATE(LEFT('Finance Forecast - Test'[FY],4), 'Finance Forecast - Test'[FYPeriod]+6, 1), DATE(2000+RIGHT('Finance Forecast - Test'[FY],2), 'Finance Forecast - Test'[FYPeriod]-6, 1)),0)

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

That is the answer of my question for anyone interested in 

EOM = EOMONTH(IF('Finance Forecast - Test'[FYPeriod]<=6, DATE(LEFT('Finance Forecast - Test'[FY],4), 'Finance Forecast - Test'[FYPeriod]+6, 1), DATE(2000+RIGHT('Finance Forecast - Test'[FY],2), 'Finance Forecast - Test'[FYPeriod]-6, 1)),0)
Anonymous
Not applicable

@Anonymous, do it in Power Query. It'll be sooooo much simpler. In PQ, split the FY column and get the first component, then create a string from Month and the new column adding "1" to obtain something like "June 1, 2019", then turn this into a real date using PQ functions or the functionality in the ribbon and then use the datetime intelligence in PQ (not in DAX!), to get the last day of the month. It's much easier done than said!... which is the best part of doing such things in PQ. And it'll be 100% error-free.

Anonymous
Not applicable

@Anonymous I am not good in Query, can you help me, please?

Anonymous
Not applicable

amitchandak
Super User
Super User

@Anonymous , Try like

EOM =
var _col = if([FYPeriod] >=6 , [FYPeriod] -6, [FYPeriod] +6)
return
eomonth(date(left([FY],4),_col,1),0)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak I don't know why my reply wasn't shown up here

the formula is incorrect again 

i cannot calculate years  

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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