Forum Discussion
jhobzvel
3 years agoFrequent Visitor
How to show values by using 2 date slicer
I have 1 table with date, employee and Salary columns like below. Date Employee Salary 4/1/2023 Liza 100 4/1/2023 Maria 150 4/1/2023 Susan 200 4/2/2023 Liza 150 4/2/2...
- Anonymous3 years ago
Hi jhobzvel ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create two separated date dimension tables as below
2. Create two slicers with the date field from the above 2 date dimension tables
3. Create a measure as below to get the values
Difference = VAR _date1 = SELECTEDVALUE ( 'Slicer1'[Date] ) VAR _date2 = SELECTEDVALUE ( 'Slicer2'[Date] ) VAR _salary1 = CALCULATE ( SUM ( 'Table'[Salary] ), FILTER ( 'Table', 'Table'[Date] = _date1 ) ) VAR _salary2 = CALCULATE ( SUM ( 'Table'[Salary] ), FILTER ( 'Table', 'Table'[Date] = _date2 ) ) RETURN IF ( ISINSCOPE ( 'Table'[Date] ), IF ( SELECTEDVALUE ( 'Table'[Date] ) IN { _date1, _date2 }, SUM ( 'Table'[Salary] ), BLANK () ), _salary2 - _salary1 )4. Create a matrix visual as below screenshot
Best Regards
Anonymous
3 years agoNot applicable
Hi jhobzvel ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create two separated date dimension tables as below
2. Create two slicers with the date field from the above 2 date dimension tables
3. Create a measure as below to get the values
Difference =
VAR _date1 =
SELECTEDVALUE ( 'Slicer1'[Date] )
VAR _date2 =
SELECTEDVALUE ( 'Slicer2'[Date] )
VAR _salary1 =
CALCULATE (
SUM ( 'Table'[Salary] ),
FILTER ( 'Table', 'Table'[Date] = _date1 )
)
VAR _salary2 =
CALCULATE (
SUM ( 'Table'[Salary] ),
FILTER ( 'Table', 'Table'[Date] = _date2 )
)
RETURN
IF (
ISINSCOPE ( 'Table'[Date] ),
IF (
SELECTEDVALUE ( 'Table'[Date] ) IN { _date1, _date2 },
SUM ( 'Table'[Salary] ),
BLANK ()
),
_salary2 - _salary1
)
4. Create a matrix visual as below screenshot
Best Regards