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

Addcolumns -- Referencing previously added column in calculate

Hi all,

 

I'm writing a query with Addcolumns and need the result of previously added columns for further columns. To achieve this I'm nesting Addcolumns to use column references of columns added in the previous Addcolumns. 

Please see example below.

 

Addcolumns 1.JPG

 

Now I would need to use a previously added column in a new column using calculate, but referencing the column in calculate does not work

Addcolumns 2.JPG

Addcolumns 3.JPG

 

 

Why can I reference the [C2] column in DIVIDE but not in CALCULATE?

 

Thanks in advance.

 

Best regards

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @ITManuel,

 

The '[C2]' column is a generated column in the virtual table, it was not generated when you referenced [C2] in the virtual table.
If you want to reference [C2], you need to create the metric to reference it after the calculation table is generated.

vxulinmstf_0-1627614230968.png

 

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @ITManuel,

 

The '[C2]' column is a generated column in the virtual table, it was not generated when you referenced [C2] in the virtual table.
If you want to reference [C2], you need to create the metric to reference it after the calculation table is generated.

vxulinmstf_0-1627614230968.png

 

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

CNENFRNL
Community Champion
Community Champion

Here's a former thread on this subject

Solved: DAX: Is it possible to refer to columns of a table... - Microsoft Power BI Community


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

ITManuel
Responsive Resident
Responsive Resident

Hi @CNENFRNL ,

 

thank you for linking the thread, I read it a few times, but can still not fully understand why I can reference the column in a function like "DIVIDE" but cannot reference it in "CALCULATE". 

 

Any further explanation and solution is much appreciated. 

 

Thanks

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.