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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Majidbhatti
Advocate IV
Advocate IV

Find the difference TODAY minus YESTERDAY data with visual slicer

In the below matrix, I am trying to find the difference TODAY minus YESTERDAY data. So in the below example, when user selects AS ON date which is 4 Nov, I have to show the difference in the forecast TODAY minus YESTERDAY for DEC 2019.

 

I am able to get the Totals of 4 Nov in the matrix but I am not able to get the YESTERDAYS data as the matrix is being filtered on the 4 Nov. My measure is as follows. I am not able to exclude the filter. I know there is a way to go in "Edit Interactions" and exclude but i want formula based exclusion. 

 

M3 =
VAR PMSdate = SELECTEDVALUE('OTB Snapshots'[PMSDate].[Date], TODAY())
Var ValDiff =
            Sum('OTB Snapshots'[Room Nights - OTB]) -
              CALCULATE( Sum('OTB Snapshots'[Room Nights - OTB]),
                  FILTER( 'OTB Snapshots',
                      'OTB Snapshots'[PMSDate].[Date] = PMSdate - 1
                    )
              )
Return
     ValDiff 

 

Capture.PNG

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Majidbhatti 

 

could you try this code:

M3 =
VAR PMSdate =
    SELECTEDVALUE ( 'OTB Snapshots'[PMSDate].[Date], TODAY () )
VAR ValDiff =
    SUM ( 'OTB Snapshots'[Room Nights - OTB] )
        - CALCULATE (
            SUM ( 'OTB Snapshots'[Room Nights - OTB] ),
            FILTER (
                ALL ( 'OTB Snapshots'[PMSDate] ),
                'OTB Snapshots'[PMSDate] = PMSdate - 1
            )
        )
RETURN
    ValDiff

 

Cheers,
Sturla

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Majidbhatti 

 

could you try this code:

M3 =
VAR PMSdate =
    SELECTEDVALUE ( 'OTB Snapshots'[PMSDate].[Date], TODAY () )
VAR ValDiff =
    SUM ( 'OTB Snapshots'[Room Nights - OTB] )
        - CALCULATE (
            SUM ( 'OTB Snapshots'[Room Nights - OTB] ),
            FILTER (
                ALL ( 'OTB Snapshots'[PMSDate] ),
                'OTB Snapshots'[PMSDate] = PMSdate - 1
            )
        )
RETURN
    ValDiff

 

Cheers,
Sturla

Bravo, its working fine ...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.