Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jhobzvel
Frequent Visitor

How to show values by using 2 date slicer

 I have 1 table with date, employee and Salary columns like below.

 

DateEmployeeSalary
4/1/2023Liza100
4/1/2023Maria150
4/1/2023Susan200
4/2/2023Liza150
4/2/2023Maria250
4/2/2023Susan125
4/3/2023Liza125
4/3/2023Maria150
4/3/2023Susan100
4/4/2023Liza125
4/4/2023Maria100
4/4/2023Susan205
4/5/2023Liza150
4/5/2023Maria200
4/5/2023Susan200

 

My goal is to calculate the difference of salary between 2 dates - 2 slicer dates.

 

Example:

Slicer Date 1 = April 1 
Slicer Date 2 = April 5 

 

Then I will create a measure to calculate for the difference (Slicer Date 2 - Slicer Date 1) and the visual should look like:

EmployeeApril 1April 5Difference
Liza10015050
Maria15020050
Susan2002000

 

I can't make this one to work. Any idea if this is possible?

1 ACCEPTED SOLUTION
Anonymous
Not 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

vyiruanmsft_0-1682043683755.png

2. Create two slicers with the date field from the above 2 date dimension tables

vyiruanmsft_1-1682043793562.png

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

vyiruanmsft_2-1682043821022.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not 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

vyiruanmsft_0-1682043683755.png

2. Create two slicers with the date field from the above 2 date dimension tables

vyiruanmsft_1-1682043793562.png

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

vyiruanmsft_2-1682043821022.png

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.