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
vishnuprashanth
Helper III
Helper III

Add the calculated column as custom column into the table in Query Editor

I have created a calculated column in my data model. I want to create or add this calculated column to a new custom column in the Edit Query Table. 

Max Value_Week = 
CALCULATE ( MAX ( Table[Value] ), ALLEXCEPT ( Table, Table[Person], Table[WeekSequence] ) )


Is it possible to copy the calculated column to the table in Query Editor? or, can anyone suggest me how to convert this DAX function to M query to add the new column to the table, please? 

TIA

10 REPLIES 10

You can’t access calculated columns from the query editor. Also, chances are the calculated column is not the best approach anyway (I can’t be sure because I don’t know what it is, but based on experience there may be a better way). What is in the calc column?

 

You may be interested in my article here https://exceleratorbi.com.au/calculated-columns-vs-measures-dax/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi @MattAllington, Thanks for your response. 

The calculated column has the maw_value for each week/ person. Please find the attached screenshot below.ed.png

 

My dataset has only 3 columns - Person, Value and Weeks. I need to create a custom column with Max Value(calculated using the DAX formula mentioned above) to my table in the Query Editor. 

You say “all I need now....” but I don’t think this is what you need at all. What are you wanting to achieve?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

@MattAllington

 

I have created a calculated column in my data model - Max Value_Week

Calculated column is Max Value_WeekCalculated column is Max Value_Week

 

Now, I want to create a custom column in my table in the query editor and want to fill in the max_value_week values, either by writing an M query. 

 

add Max Value_Week to this table and calculate its values using the M Queryadd Max Value_Week to this table and calculate its values using the M Query

I understand what you are saying, but my advice to you is that this is likely to be the wrong way to solve your problem.  Can you put aside this for a moment and take a step back.  Why do you want to do what you say?  What are you planning to do with this once it is done?  There is likely a better way.  Please describe the end state.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

@MattAllington Apologies for not being clear. 

 

I will try and explain my problem and the output I am expecting in detail.  I have the below-attached dataset.Actual DatasetActual Dataset

Then I created calculated columns(marked below) for the variables. 

calculated coulmnscalculated coulmns

 

I unpivoted the columns to have them in the same columns as attributes. 

 

unpivoted columnsunpivoted columns

 

 

 

I needed to create a graph as shown below. .. But since I have unpivoted the columns, my calculated columns are throwing me an error as """Column 'max P ' in table 'PT2' cannot be found or may not be used in this expression."""

 

so, I thought of creating those columns in the table directly to create a bar chart like this.. 

 

Create bar chart for comparing the attributesCreate bar chart for comparing the attributes

 

 

 

@MattAllington Hi Matt,

Do you have any suggestions for me to implement this kind of report, please?

Just got an Idea Matt. Let me try it tomorrow and see if that is working. Thanks a lot for your response. I will try that and let you know if I managed to solve the problem. 

Thanks again 🙂 

Hi @vishnuprashanth,

I am not sure that I completely follow what you are after, but could you not just add the field a second time to the values of the visualization and change the aggregation to Maximum.  As shown below where I added a field named hours to a chart twice, once as the sum and a second as the Maximum.

Sample 02-22-2018.PNG

Hi @MarkS

I have already tried it. If I do like that, the labels are shown as Legends and are not displayed in the X-Axis.  want the labels to be displayed on the X-Axis. 

fz.PNG


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.