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
MaxSchrijen23 , Seem like you need to refer to two date range slicers. Refer if this can help
How to use two Date/Period slicers
if one table is the independent date table then for second range
//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = _max -5
return
calculate( sum(Table[Value]), filter(all('Date'), 'Date'[Date] >=_min && 'Date'[Date] <=_max))
the other range should work as it coming from connected date table
- MaxSchrijen234 years agoHelper I
Thanks for your reply!
It is only net yet clear to me what you mean exactly, could you maybe attach a PBI file with an example of how it would look? And why do I need two slicers, cant I have one slicer showing a date range and then select the maximum and minimum date in between this range?
Next to this, I am really struggling with then returning the value that belong to this min and max date, could you also explain that?
Kind regards