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
Datagulf
Responsive Resident
Responsive Resident

Date Table Creation Queries

Hi community.
I am creating a Date Table that I do not require to always input the columns but one stack of code. As I was creating it, I had a problem which was referencing other columns in a new column. 
It became quite hard to use quoted columns above in the same code.
The pbix with the Date table with the errors is here. Thanks.
 Date pbix file 

2 ACCEPTED SOLUTIONS
v-janeyg-msft
Community Support
Community Support

Hi, @Datagulf 

 

I checked your code, and saw you use 'addcoumn' function to create your date table, you should know that the new columns are side by side, so you can’t refer to one column from another.

vjaneygmsft_1-1634886866093.png

You have two ways, one is to use addcolumn nested, so that the following columns can refer to the column names in the previous table.

vjaneygmsft_0-1634886811493.png

The second is to create a new column in the form of a calculated column.

vjaneygmsft_3-1634887107909.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

View solution in original post

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @Datagulf 

 

I checked your code, and saw you use 'addcoumn' function to create your date table, you should know that the new columns are side by side, so you can’t refer to one column from another.

vjaneygmsft_1-1634886866093.png

You have two ways, one is to use addcolumn nested, so that the following columns can refer to the column names in the previous table.

vjaneygmsft_0-1634886811493.png

The second is to create a new column in the form of a calculated column.

vjaneygmsft_3-1634887107909.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

THis is awesome @v-janeyg-msft . 

amitchandak
Super User
Super User

@Datagulf , Date is the only column you have available for add columns to use. All your calculation should be based on that.

 

Not very clear what you want to do there, But have the same var there in other columns and try.

 

example

 

"Day",VAR Current_Year = RIGHT(YEAR([Date]),2)
VAR Last_Year = RIGHT(YEAR([Date])-1,2)
VAR Next_Year = RIGHT(YEAR([Date])+1,2)
VAR Fiscal_Year =
    IF(
        MONTH([Date]) >= 4,
        Current_Year & "/" & Next_Year,
        Last_Year & "/" & Current_Year
    )
RETURN  FORMAT ( [Date], CONCATENATE("dd-ddd-mmm ", Fiscal_Year)),

@amitchandak What I am trying was to use already quoted columns to create other columns but I guess from your comment, that is impossible and one can only use the Date Column in reference to creating other columns, right?

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.