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

Current Month starting from the 16th

Hello 🙂

 

I am currently trying to create a column for the current month. I have created a DimDate Table where i want the column to be. I have used the following code to make a yes/no indication according to, if the month is the current month. I have used the following code:

 

IsToday = 
var Currentrowdate = FORMAT(DimDate[Date]; "mm/yyyy")
var istoday = FORMAT(NOW(); "mm/yyyy")
return
IF(istoday = Currentrowdate; "Yes"; "No")

 

I would like the current month to start from the 16th-15th in the next month. So for example from the 16th of July to the 15th of August. It should be possible to auto update the current month, so that code have to be dynamic.

 

Thank you in advance 🙂

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Anonymous 

I found a way to make it work! I just changed your code a bit. Thank you so much! the code is:

 

FNyear = 
Var First = FORMAT(IF(DimDate[DayofMonth]>=16;DATE(DimDate[år];DimDate[Monthof Year]+1;16);IF(DimDate[DayofMonth]<=15;DATE(DimDate[år];DimDate[Monthof Year];16)));"MM/YYYY")
var second = FORMAT(NOW();"MM/YYYY")

return 
IF(First = second;"yes";"No")

View solution in original post

Anonymous
Not applicable

hi @Anonymous ,

 

see this one,

 

Column = 
 
Var First = FORMAT(IF('Table'[Day]>=16, DATE('Table'[Year],'Table'[Month]+1,16),IF('Table'[Day]<=15,DATE('Table'[Year],'Table'[Month],16))),"MMyyyy")
var second = FORMAT(NOW(),"MMYYYY")

return
IF(First = second,"yes","No")
 
 
regards,
naveen

View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

 

I found a solution! 😄 

the code is :

 

Lastmonth = 
Var First = FORMAT(IF(DimDate[DayofMonth]>=16;DATE(DimDate[år];DimDate[Monthof Year]+2;16);IF(DimDate[DayofMonth]<=15;DATE(DimDate[år];DimDate[Monthof Year]+1;16)));"MM/YYYY")
var second = FORMAT(NOW();"MM/YYYY")

return 
IF(First = second;"yes";"No")

Thank you so much for your help ! 😄

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Anonymous 

I found a way to make it work! I just changed your code a bit. Thank you so much! the code is:

 

FNyear = 
Var First = FORMAT(IF(DimDate[DayofMonth]>=16;DATE(DimDate[år];DimDate[Monthof Year]+1;16);IF(DimDate[DayofMonth]<=15;DATE(DimDate[år];DimDate[Monthof Year];16)));"MM/YYYY")
var second = FORMAT(NOW();"MM/YYYY")

return 
IF(First = second;"yes";"No")
Anonymous
Not applicable

hi @Anonymous ,

 

Try this formula,

 

FNyear =
Var First = FORMAT(IF('Table'[Day]>=16, DATE('Table'[Year],'Table'[Month],16),IF('Table'[Day]<=15,DATE('Table'[Year],'Table'[Month]-1,16))),"MMyyyy")
var second = FORMAT(NOW(),"MMYYYY")

return
IF(First = second,"yes","No")
 
Capture.JPG
 
Anonymous
Not applicable

hi @Anonymous 

 

It almost works! 😄

 

I want the current month to start from the 16th of last month. So from the 16th of july. The code you have provided gave me the current month from the 16th of august. I have tried to change the code but i can not get it to work so that the start of the month is for the 16th of last month. 

Anonymous
Not applicable

hi @Anonymous ,

 

see this one,

 

Column = 
 
Var First = FORMAT(IF('Table'[Day]>=16, DATE('Table'[Year],'Table'[Month]+1,16),IF('Table'[Day]<=15,DATE('Table'[Year],'Table'[Month],16))),"MMyyyy")
var second = FORMAT(NOW(),"MMYYYY")

return
IF(First = second,"yes","No")
 
 
regards,
naveen
Anonymous
Not applicable

Hi @Anonymous 

 

I found a solution! 😄 

the code is :

 

Lastmonth = 
Var First = FORMAT(IF(DimDate[DayofMonth]>=16;DATE(DimDate[år];DimDate[Monthof Year]+2;16);IF(DimDate[DayofMonth]<=15;DATE(DimDate[år];DimDate[Monthof Year]+1;16)));"MM/YYYY")
var second = FORMAT(NOW();"MM/YYYY")

return 
IF(First = second;"yes";"No")

Thank you so much for your help ! 😄

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.