Forum Discussion
Creating a date column
- 3 years ago
Hi, Anonymous
Thanks for your quick response!
When the [Period]=1, the date is the Dec in the last year.Here are the steps you can refer to :
We can click "Custom Column" and enter this:
if [Period]=1 then #date([FY]+2000-1,12,1) else #date([FY]+2000,[Period]-1,1)Then we can modify the data type we want :
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , Anonymous
According to your description, you want to generate a date column in Power Query according to the other columns?
First in Power Query , we can click "Custom Column" to add a column we need:
Second, we can use IF() function to judge the other columns value and use the #date(2022,1,1) to generate a date value.
For your company logic , i am not fully understand , if the above method can not meet your need , you may provide some sample data and then detailed explanation for your need and the end result as a table to us .
It will may be more clearly.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Anonymous3 years agoNot applicable
Hi Aniya, thanks for your support so far!!
I have replicated what I want to obtain in Excel:
I have calculate the rightmost table using the following excel formula:
=DATE(IF([@Period]=1;[@FY]+2000-1;[@FY]+2000);IF([@Period]=1;12;[@Period]-1);1)
I need to replicate exacly the same in powerpivot creating a new column. Unfortunately all attempts I did resolved eitheir in sintax or in data error. For example the following:
= Table.AddColumn(#"Replaced Value", "Merged", each Text.Combine({"20", Text.From([FY], "it-IT"), Text.From([Period], "00"), "-01"}), type text)
produce data "error" in all records.
Many thanks,
C.
- v-yueyunzh-msft3 years agoCommunity Support
Hi, Anonymous
Thanks for your quick response!
When the [Period]=1, the date is the Dec in the last year.Here are the steps you can refer to :
We can click "Custom Column" and enter this:
if [Period]=1 then #date([FY]+2000-1,12,1) else #date([FY]+2000,[Period]-1,1)Then we can modify the data type we want :
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Anonymous3 years agoNot applicable
Thanks Aniya, this did work!
Regards and thanks again!
C.