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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Cromero3000
Helper I
Helper I

Error making month name measure - HELP

Hello Team!,

I'm new in Power Bi and I'm learning about measures. I started creating a Calendar table only with DAX but I'm having problem creating a column to show the month name. Let me show you what I've done:

 

ER1.PNG

 

So, I want to create a column #5 the same as #4 with the difference that I need to show the Month's name instead of Day's name, therefore the formula would be slightly the same as column 4 as follows:

 

ER2.PNG

Right?? but I doesn't work!, for some reason is not recognizing the "Calendar[Date]" column and is giving me the below error:

 

PBError.PNG

 

Why? why does this happens? I mean, why did it work on Column 4 but it doesn't work on Column 5? it is the same formula with different name. I can't even replicate Column#3, it is like the "Calendar[Date]" column doesn't exist because it is not recognizing it.

 

Please your help. Thanks in advance!!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write that formula as a calculated column - not as a measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

Write that formula as a calculated column - not as a measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur , it worked! thank you!. So, If I have learned correctly, does that means that only the first column has to be a measure and the rest of them need to be "calculated column"?? why is that? I mean, if a calculated column is an internal measure, why can't I manually make a measure for each column? sorry, just trying to understand how this works Smiley Sad

 

Thank you

You are welcome.  Columns 2, 3 and 4 should defeinitely be calculated columns.  Column 3 formula should be

Day = DAY(Calendar[Date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you @Ashish_Mathur , it worked both ways for column 3:

  • Day of Month = 'Calendar'[Date].[Day]
  • Day = DAY(Calendar[Date])

 

I'll stay with your suggestiong. I still don't get why it has to be a calculated column and not an independent measure.

 

Regards!

Hi @Cromero3000 ,

When we create calculated columns, we could use the column from the original table directly. However, we need to use a function to get values when create measures.  Because measures need context. I suggest you to reference some documents to learn what differences between calculated columns and measures and how to choose them.

There is a blog about it. I think you could reference firstly.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/ 

 

Please mark the helpful answer as a solution. Then we are able to close the thread. More people will find the answer quickly and benefit here.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jdbuchanan71
Super User
Super User

Hello @Cromero3000 

Try changing your column 3 to be

Day Number = DAY ( 'Calendar'[Date] )

By using 'Calendar'[Date].[Day] you are getting into the auto time intelligence functions in PowerBI which you want to avoid (you end up with a date table for every column with dates) and that is why you are making your own calendar table.3

You can also make the table in one larger measure which makes it easier to use in another book (you just copy the code, go to the new book, hit new table and paste it in).

Calendar = 
VAR DateRange = CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2025, 12, 31 ) )

RETURN 
ADDCOLUMNS(
    DateRange,
    "Day of Week", WEEKDAY ( [Date] ),
    "Day Number", DAY ( [Date] ),
    "Name of Day", FORMAT ( [Date], "DDDD"),
    "Month Name", FORMAT ( [Date], "MMMM" )
)

You can add as many additional columns as you need all in this one measure.

Thank you @jdbuchanan71 !, your formula worked great, the only difference is that is displaying weeks of the month and not every day of the month. 

I tried to make a minimal change as shown below:

Calendario = 
VAR DateRange = CALENDAR(DATE(2018,1,1), DATE(2025,12,31))

RETURN
ADDCOLUMNS(
    DateRange,
    "Day of Week", WEEKDAY([Date],2),
    "Day Number", DAY([Date]),
    "Day name", FORMAT([Date], "DDDD"),
    "Month name", FORMAT([Date], "MMMM"),
)
But is giving me the below error:
ER3.PNG
I don't get it, is practically the same as your formula and it gives me the error.
 
What am I missing? sorry, geting bold pulling out my hair in here.
 
 
 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.