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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
CMAC_Terry
Helper I
Helper I

Sales for Same Period Last year relative to a Year Slicer / Filter

Need some guidance to see if I'm going about this the right way.

 

I'm trying to create a YoY sales Variance that calculates the variance relative to the year selected in a Year filter; this is so the consumer can click through years; see that years sales and the variance +/- to previous year. 

 

I've been able to calculate the selected Years' Sales relative to the slicer with this below, but the when I try to create the year before sales, same calculation but amending the: YEARSTART-1 and YEAREND-1) relative to the slicer it returns blank.

 

Total Job Bill = 
VAR
    YEARSTART    =  SELECTEDVALUE( FactJobEntry[Key Date.Year] , MIN( FactJourney[Key Date.Year] ) ) 
VAR 
    YEAREND      =  SELECTEDVALUE( FactJobEntry[Key Date.Year] , MAX( FactJourney[Key Date.Year] ) )
VAR
    TOTALJOBBILL =  SUM( FactJobEntry[Bill Net] ) 
RETURN
  CALCULATE( TOTALJOBBILL,
      DATESBETWEEN( FactJobEntry[Key Date],  
      DATE( YEARSTART, 1, 1 ) , DATE( YEAREND, 12, 31 ) )
      )

 

 

 

1 ACCEPTED SOLUTION
CMAC_Terry
Helper I
Helper I

Found an answer using 

Total PY Job Bill = 
IF ( 
  ISCROSSFILTERED( DimCalendar[DimYear] ),
  CALCULATE( [Total Job Bill],
  SAMEPERIODLASTYEAR( DimCalendar[Date] )),
  BLANK())

View solution in original post

1 REPLY 1
CMAC_Terry
Helper I
Helper I

Found an answer using 

Total PY Job Bill = 
IF ( 
  ISCROSSFILTERED( DimCalendar[DimYear] ),
  CALCULATE( [Total Job Bill],
  SAMEPERIODLASTYEAR( DimCalendar[Date] )),
  BLANK())

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors