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
apagan
Helper I
Helper I

Attempting to use a Measure to display Month (stored as Integer) as text value

I am retreiving data from a table that stores a month as an integer (i.e., January = 1, February = 2, etc.) and I want to display that number as a text value in a graph.  I've attempted to use a measure to create a text value for the month, but am getting the error message, "A single value for column 'SampledMonth' in table 'LocationVisits' cannot be determined.'

 

Here is the formula that i am using:

 

Month = if(LocationVisits[SampledMonth]=4,"April","")

 

What am i doing wrong?

 

Thanks!

1 ACCEPTED SOLUTION
v-micsh-msft
Employee
Employee

Hi apagan,

 

As shared, a measure is not recommended to put into X-Axis.

In addition, for the month, if all the months value that show in your table are in a same year, then we could create a reference table, which matchs month number with month name;

For example:

Month Num |  Month Name

                 1  |   Jan

                 2  |   Fer

Input all the month values, then create a relationship under Relationship View in Power BI Desktop. After that, put the Month Name as the X-Axis in the visual.

Another way is create a calculated column with switch function:

 

Month Name = SWITCH(LocationVisits[SampledMonth], 1, "January", 2, "February", 3, "March", 4, "April" 
               , 5, "May", 6, "June", 7, "July", 8, "August" 
               , 9, "September", 10, "October", 11, "November", 12, "December" 
               , "Unknown month number" )

And if your data table contains month in different years, we need the year information also included in the column (we could use format function here), or in the calculation filters (to filter with the same year), well this depends on your data sample.

Please reply back if you need any further assistance on this.

Regards

View solution in original post

3 REPLIES 3
v-micsh-msft
Employee
Employee

Hi apagan,

 

As shared, a measure is not recommended to put into X-Axis.

In addition, for the month, if all the months value that show in your table are in a same year, then we could create a reference table, which matchs month number with month name;

For example:

Month Num |  Month Name

                 1  |   Jan

                 2  |   Fer

Input all the month values, then create a relationship under Relationship View in Power BI Desktop. After that, put the Month Name as the X-Axis in the visual.

Another way is create a calculated column with switch function:

 

Month Name = SWITCH(LocationVisits[SampledMonth], 1, "January", 2, "February", 3, "March", 4, "April" 
               , 5, "May", 6, "June", 7, "July", 8, "August" 
               , 9, "September", 10, "October", 11, "November", 12, "December" 
               , "Unknown month number" )

And if your data table contains month in different years, we need the year information also included in the column (we could use format function here), or in the calculation filters (to filter with the same year), well this depends on your data sample.

Please reply back if you need any further assistance on this.

Regards

vickyprudhvi
Helper IV
Helper IV

HI,

are you palnning to show months on x- axis?

you need to create calcualted column and not measure for it. As per my knowledge measures can't be used in Axis. Measures are used in Values section of the visual

 

 

Thank you!

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.