Forum Discussion
apatwal
4 years agoHelper III
Based on Invoice Date filter, create two separate columns
Hi, I need a help in creating below two columns using DAX I have a calculated column for "Net Change in Cost $", and using this column I have to create below two columns 1. Net Change in Cost ...
- 4 years ago
Dear apatwal
Columns do not have access to the filter context and hence cannot read any filter. However, you can achieve the same by creating two measures as the values of a matrix visual sliced by transaction number or any other column.
Supposing that the date filter will come only from the slicer (meaning it is not part of the visual) then the first measure can be:Net Change in Cost $ - Full Date = CALCULATE ( SUM ( 'Table'[Net Change in Cost $] ), ALLSELECTED ( 'Table'[Invoice Date] ) )For the 2nd measure try
Net Change in Cost $ - Last 4 Weeks = VAR EndtDate = MAX ( 'Table'[Invoice Date] ) VAR StartDate = EndtDate - 28 VAR Result = CALCULATE ( SUM ( 'Table'[Net Change in Cost $] ), FILTER ( 'Table', 'Table'[Invoice Date] < EndtDate && 'Table'[Invoice Date] >= StartDate ) ) RETURN ResultPlease let me know if works. If so kindly mark my reply as accepted solution. Thank you!