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
adityavighne
Continued Contributor
Continued Contributor

Add target column to calculated table

Hi,

 

I have calculated column and I want to add target for that and get difference value. How can I do this.

 

Name,Open,Close and total is calculated table and Target, Difeerence column I want to add

 

NameOpenCloseTotalTargetDifference

A

1020305020
B56116049
C20507010030

 

How can I add this and display.

 

Regards,

Aditya Vighne

10 REPLIES 10
Icey
Community Support
Community Support

Hi @adityavighne ,

 

Please provide more details to help us understand what you want.

 

 

Best Regards,

Icey

Icey
Community Support
Community Support

Hi @adityavighne ,

 

Is this problem solved?


If it is solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.


If not, please let me know.

 


Best Regards,
Icey

adityavighne
Continued Contributor
Continued Contributor

No this problem is still not solved

Please can you provide further detail then on what hasn't worked about the suggested solutions?

Please @mention me in your reply if you want a response.

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

Ashish_Mathur
Super User
Super User

Hi,

Create a seperate 2 column Table with Names in column A and targets in column B.  Create a relationship from the Names in your existing table to the Names in the new 2 column table.  In your existing table, write these calculated column formulas:

Targets = related(table1[Target])

Difference = [targets]-[total]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

You have targets for each "Name" in a different table which you want to bring in this calculated table or you want to add the values by hard-coding them in the DAX and add it here?

@Anonymous  

I want to add target for each by hard coding.

Anonymous
Not applicable

I think you should maintain your targets in a separate table, but if you want to hard-code it, you could do so as others suggested here using SWITCH. Refer to the screenshot below..

PBIAddTargets.png

 

 

@adityavighne I think creating a table as @Anonymous suggested and loading that into the Data Model would be a better solution, but you could use a Switch or IF to hard code this using ADDCOLUMNS or similar table constructor:

NewTable= ADDCOLUMNS(CalculatedTable, "Target", SWITCH(CalculatedTable[Name], "A", 50, "B", 60, "C", 100)

The difference can be added as a Calculated column or added into that table expression.

See this solution from @v-lili6-msft for what we mean by having the target table stored in the data model and how to set that up with relationships (in your case replace 'year' with 'name')
https://community.powerbi.com/t5/Desktop/Adding-annual-target-to-existing-table/td-p/579550

Please @mention me in your reply if you want a response.

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
Not applicable

Hi,

 

You can use SWITCH statement to list target as 50 for A , 100 for B , 150 for C etc. SWITCH ("ColumnA","A",50,"B",100,"C",150,0)

 

Regards

Rohit

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.