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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Adam13Hylo
Helper I
Helper I

Custom Column Query

Hi all,

 

Wondering if someone can help me please. I have trying to write a query so that if a column is less than 8 then this will combine a string and another column. However for some reason it is continiously showing blank.

 

The formula I have is: 

if [ReportingMonthNum] < 8 then "FY" & [YearNum] else ""

 

The reporting monht column has values ranging from 1 to 13 and the "YearNum" will show our year number for example, 15, 16 or 17 etc... I am trying to combine this with some text "FY" however my columns are continuing to show blank.

 

Can anyone point me as to where I am going wrong please.

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

You can't concatenation text with numbers. Convert the number first.

 

Number.ToText([YearNum])



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

7 REPLIES 7
MattAllington
Community Champion
Community Champion

You can't concatenation text with numbers. Convert the number first.

 

Number.ToText([YearNum])



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Thank you this worked, however this is ignoring double numbers for instance I have added to the query so that if th Reporting Month is greater than or equal to 8 however this does not work if the number is 10, 11, 12 etc... Might you have any ideas why please?

Sorry, I don't understand. Can you post your new formula?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Sorry Matt, 

 

My formula is now: 

if Number.ToText([ReportingMonthNum]) < "8" then "FY" & Number.ToText([YearNum]) else if Number.ToText([ReportingMonthNum]) >= "8" then "FY" & Number.ToText(Value.Add([YearNum], 1)) else ""

 

In the formula it should be that if the "ReportingMonthNum" is greater or equal to 8 then the value should be FY & the year number plus 1, this works for months 8 & 9 however it does not work for months 10, 11 or 12:

PowerBi.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It appears to be ignoring numbers with anything more than two digits. 

The issue is just after your second "if". You should not be using Number.ToText for the comparator, just for the concatenation. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Still does not work sorry, my query is now: 

if [ReportingMonthNum] < "8" then "FY" & Number.ToText([YearNum]) else if [ReportingMonthNum] >= "8" then "FY" & Number.ToText(Value.Add([YearNum], 1)) else ""

 

The Year Number column has a type of whole number as did the reporting month but I have changed this back to the default now.

 

Column ValuesColumn Values


Try changing Value.Add([yearnum],1) to simply [yearnum] + 1



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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