Forum Discussion
Calculated column on date range
- Anonymous4 years ago
Hi MaxSchrijen23 ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. Please create a measure as below, since you want the values change base on the date slicer selections....
Measure = VAR _selproject = SELECTEDVALUE ( 'Table'[ProjectName] ) VAR _selcat = SELECTEDVALUE ( 'Table'[Category] ) VAR _mindate = CALCULATE ( MIN ( 'Table'[ChangeDate] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ProjectName] = _selproject && 'Table'[Category] = _selcat ) ) VAR _maxdate = CALCULATE ( MAX ( 'Table'[ChangeDate] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ProjectName] = _selproject && 'Table'[Category] = _selcat ) ) VAR _mindvalue = CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[ProjectName] = _selproject && 'Table'[Category] = _selcat && 'Table'[ChangeDate] = _mindate ) ) VAR _maxdvalue = CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[ProjectName] = _selproject && 'Table'[Category] = _selcat && 'Table'[ChangeDate] = _maxdate ) ) RETURN SWITCH ( TRUE (), _mindvalue = "Red" && _maxdvalue = "Green", "Up", _mindvalue = "Green" && _maxdvalue = "Red", "Down", _mindvalue = _maxdvalue, "Same" )And you can review the following links to get more details on the difference between calculated column and measure.
Calculated Columns and Measures in DAX
Calculated Columns vs Measures
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi MaxSchrijen23 ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. Please create a measure as below, since you want the values change base on the date slicer selections....
Measure =
VAR _selproject =
SELECTEDVALUE ( 'Table'[ProjectName] )
VAR _selcat =
SELECTEDVALUE ( 'Table'[Category] )
VAR _mindate =
CALCULATE (
MIN ( 'Table'[ChangeDate] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[ProjectName] = _selproject
&& 'Table'[Category] = _selcat
)
)
VAR _maxdate =
CALCULATE (
MAX ( 'Table'[ChangeDate] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[ProjectName] = _selproject
&& 'Table'[Category] = _selcat
)
)
VAR _mindvalue =
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[ProjectName] = _selproject
&& 'Table'[Category] = _selcat
&& 'Table'[ChangeDate] = _mindate
)
)
VAR _maxdvalue =
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[ProjectName] = _selproject
&& 'Table'[Category] = _selcat
&& 'Table'[ChangeDate] = _maxdate
)
)
RETURN
SWITCH (
TRUE (),
_mindvalue = "Red"
&& _maxdvalue = "Green", "Up",
_mindvalue = "Green"
&& _maxdvalue = "Red", "Down",
_mindvalue = _maxdvalue, "Same"
)
And you can review the following links to get more details on the difference between calculated column and measure.
Calculated Columns and Measures in DAX
Calculated Columns vs Measures
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
- MaxSchrijen234 years agoHelper I
Thanks, your solution works perfect!
There is however one small thing, when I apply this to an XLS based input it works perfect but when I try to apply the exact same logic to on input coming from a live connection it does only work for some items. Could you explain this?