Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

need a dax function to create new column using values from single column

I need to create a column from the value column with formula = standard material/ total sales

where type month and opco for std material and total sales are same as shown 

please help as I am not being able to segregate this.

 

QUES.jpg

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Don'@Harsh333,

Here are the steps you can follow:

1. Create a calculated column.

Column =
var _value=CALCULATE(SUM('Table'[VALUE]),FILTER('Table',[Category]="STANDARD MATERIALS"&&[Type]=EARLIER('Table'[Type])&&[Months]=EARLIER('Table'[Months])))
var _total=CALCULATE(SUM('Table'[VALUE]),FILTER('Table',[Category]="TOTAL SALES"&&[Type]=EARLIER('Table'[Type])&&[Months]=EARLIER('Table'[Months])))
var _1=DIVIDE(_value,_total)
return IF([Category]="TOTAL SALES",_1,BLANK())

2. Result.

v-yangliu-msft_0-1608886970257.png

You can download the PBIX file from here.

Best regards

Liu Yang

If this post helps,then consider Accepting it as the solution to help other members find it faster.

PaulDBrown
Community Champion
Community Champion

@Anonymous 

Is there a specific reason you need this is a column in your table? These sort of calculations are normally done using measures





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

sorry for late reply,

this formula has returned blank values.

amitchandak
Super User
Super User

@Anonymous , Create a new column in the table like this and try

 


new column =
var _SM = sumx(filter(table, [type] = earlier([type]) && [month] = earlier([month]) && [category] ="STANDARD MATERIAL"),[value])
return
if([category] ="TOTAL SALES" , divide(_SM,[value]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.