Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
Hello everyone,
New to PBI and not sure how to get the syntax right for my simple need.
I have a date column "DATE" with dates ranging from year 2017-2020.
Want to create a new column based on "DATE" column's year.
say for date (dd-mm-yyyy) -
01-01-2017 the new column should reflect mynaming_2017,
01-01-2018 the new column should reflect mynaming_2018 and so on.
where, mynaming is something i would like to concatenate the year part with.
Please help with the right approach.
Solved! Go to Solution.
Hi @Anonymous,
Maybe you can try to use t-sql query in your connector to add a custom column that formats your date fields and concatenate with current username.
Notice: current store procedure not able to use in 'direct query' mode.
Regards,
Xiaoxin Sheng
Hi @Anonymous,
Maybe you can try to use t-sql query in your connector to add a custom column that formats your date fields and concatenate with current username.
Notice: current store procedure not able to use in 'direct query' mode.
Regards,
Xiaoxin Sheng
Thanks everyone for your help.
Using M query approach works but needs me to switch the connection type to import which is less perferred due to data size.
Using DAX approach I am unable to use FORMAT fucntion on direct query mode.
Error says: FORMAT is not allowed as part of calculated columns DAX expressions on direct query models.
Can you please help @amitchandak @AllisonKennedy
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@Anonymous , You can use the format
make sure date is detected as a date -https://community.powerbi.com/t5/Desktop/How-to-apply-UK-date-format-dd-mm-yyyy-in-Date-slicer/td-p/599712
New date = "MyFormat" & format([Date], "MM-YYYY")
Check the various format
https://docs.microsoft.com/en-us/power-bi/desktop-custom-format-strings
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @Anonymous
Create duplicate column in Power Query Editor of the date column and transform as below.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Regards,
Pranit
Hello Pranit,
Thanks for the reply,
I have extracted the datepart from the date field.
Not sure how i can add a dummy column with any random value (say mytablename) and then later concatenate this value with datepart value.
expected output for year 2017 would be
mytablename_2017
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 62 | |
| 58 | |
| 45 | |
| 21 | |
| 18 |
| User | Count |
|---|---|
| 121 | |
| 116 | |
| 37 | |
| 34 | |
| 30 |