- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
M-Query
Hi community,
Hope you all are doing well!
I've a doubt regarding Power BI M-query.
I've created an IF statement via Calculated column, which I'm looking to create in Power Query or Transform Query using M-Query.
Below is the IF statement:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will need to Add a Custom Column in Power Query.
It will be a combination of an 'if' statement :
https://gorilla.bi/power-query/if-function-in-power-query/
and Text.Right
https://learn.microsoft.com/en-us/powerquery-m/text-end
You may need other Text functions:
https://learn.microsoft.com/en-us/powerquery-m/text-functions
because you may need to change some number fields to text so that you can use them.
You can combine text in power query with '&'.
My advice is start it simply (get something basic that works) and build it step by step adding logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @HotChilli
I tried using M-query text functions.
below is the snip of the code I tried for creating Fiscal Year:
Please help me out if I'm doing anything wrong in this.
Used Text.From to convert Number to Text. I converted Month and Year datatypes to Text also
Still getting error
below is the error snip:
Please help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may try Number.ToText
https://learn.microsoft.com/en-us/powerquery-m/number-totext
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please delete all that I have scored-off and try again:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Still getting same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may try again after making this change. If it still doesn't work, please share the pbix file, if possible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Padycosmos
I tried but still same error.
Really thank you for your help. I'll try finding other ways too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[Year] is a numeric field, therefore, Text.End([Year],4) will not work, instead please try
Text.End(Number.ToText([Year]),4)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried doing the way you told
Below is the snip: for few line items it is working and for few it is not
Below is the snip of error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It appears that there is some problem with the data. Could you please change the Data type of the Fiscal Year Column to Whole number and apply the last formula again

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
01-23-2025 05:42 AM | |||
01-08-2025 07:39 AM | |||
02-10-2025 08:29 AM | |||
12-12-2022 11:29 PM | |||
02-27-2022 01:48 AM |