Forum Discussion
Calculated column using DAX
- 2 years ago
Hi, gandharv
in above you mention price-cost and you tack cost-price(f2-e2)so i take as a cost-price(f2-e2) so look at these
try below code with some changes
column= var a = tablename[model_run] var b = tablename[category] var c = tablename[time] var e = tablename[date] return sumx( filter( tablename, tablename[model_run]=a && tablename[category]=b && tablename[time]<= c && tablename[time]=e ), tablename[cost]-tablename[price] )
Sorry mate, if I misrepresented the Date column by keeping it the same date for all rows. But in reality, I have dates from 1/1/23 to 31/12/26, for each Category with Timestamp of 24 hour for each date.
Hi, gandharv
column =
var a = tablename[model_run]
var b = tablename[category]
var c = tablename[time]
var d = tablename[cost]-tablename[price]
var e = tablename[date]
return
sumx(
filter(
tablename,
tablename[model_run]=a && tablename[category]=b && tablename[time]<= c && tablename[time]=e
),
d
)- gandharv2 years agoFrequent Visitor
Hi, thanks again, I applied it but the result is wrong, In below screenshot, the Carry forward column has the correct result (manually done in excel) and the calculated column is using ur DAX.
- Dangar3322 years agoResident Rockstar
Hi, gandharv
in above you mention price-cost and you tack cost-price(f2-e2)so i take as a cost-price(f2-e2) so look at these
try below code with some changes
column= var a = tablename[model_run] var b = tablename[category] var c = tablename[time] var e = tablename[date] return sumx( filter( tablename, tablename[model_run]=a && tablename[category]=b && tablename[time]<= c && tablename[time]=e ), tablename[cost]-tablename[price] )- gandharv2 years agoFrequent Visitor
Hi Dangar,
Thank you for your help earlier. I have realised some changes in my original dataset, herewith am attaching a screenshot of dummy data which is the actual representation of my real data. Can you pls help me modify the DAX function accordingly? I have manually calculated in Excel for your clear understanding and mentioned the condition as well.