Forum Discussion
Understanding column in DAX function
- 4 years ago
Hi,
A calculated column in DAX, is a calculation made row by row within your table and using the Row context of your table (granularity of one row). Knowing this, it is useless (in a calculated column) to specify the value you are using in the calculation, it will be the value of the current calculated row.
(In theory because using DAX functions you can change the context, but that is another thing).
Whereas when you create a measure there is no calculation made, it will be made directly as you put your measure in a visual (table or chart). So the result will rely on the visual, if you make a table with year you have yearly results, if you make a table with catagory you have results by categories , or by month, project name...
So when you create a measure, as the measure might have to agregate some values (rows), you need to specify how this agregation will be processed (SUM, MAX, MIN, SELECTEDVALUE for the value on the row of your visual...).
Another way of saying it would be, that measure are taking into account the whole column so you need to specify which value you want in the column.
Hope it makes things more clear, and for the formula thanks to tamerj1 🙂
Hi beltalowda
First of all this is most propobly need to be a column because otherwise you cannot use it to slice and filter your data.
If you just want to disply the project name in the report as a measure then this can only happen when the filter context of the cell in your table or matrix visual contains only one project name. To do that you can use
ProjectShortMeasure =
IF (
HASONEVALUE ( Project[project_name] ),
CONCATENATEX (
Project,
MID (
Project[project_name],
FIND ( "-", Project[project_name], FIND ( "/", Project[project_name],, 1 ), 1 ) + 1,
5
)
)
)
- AlexisOlson4 years agoSuper User
If it's just one value, then you don't really need CONCATENATEX.
ProjectShortMeasure = VAR _Name = SELECTEDVALUE ( Project[project_name] ) RETURN MID ( _Name, FIND ( "-", _Name, FIND ( "/", _Name,, 1 ), 1 ) + 1, 5 )