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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cazc87
New Member

Previous Year Totals With Single Selection Year Slicer

Hi all,

 

I'd really appreciate help with these please, I have spent hours on this and have come close however not quite what I'm after!

 

I have these 3 tables (1 fact and two dimensions)

 

LOCATION

LOCATION_IDLOCATION_NAMESELLING_CURRENCY_CODESTATUS
1Store 1CADActive
2Store 2USDActive
3Store 3USDActive
4Store 4CADActive
5Store 5USDActive

 

DATE

DATE_DTFISCAL_QUARTER_SHORT_NAMEFISCAL_YEAR_IDFISCAL_WEEK
1/1/2022Q4202148
3/27/2021Q120218
8/8/2021Q3202127
12/25/2021Q4202147
4/28/2022Q1202213
3/25/2021Q120218
6/19/2022Q2202220

 

SALES

FULFILL_DATELOCATION_IDSALES_QUANTITY
1/1/20213215
1/1/2021114
1/1/20213914
1/1/20213812
1/1/20213913
1/1/20213911
1/1/202138

10

 

I have several slicers by FISCAL_YEAR, FISCAL_QUARTER, LOCATION_NAME but am trying to sum the SALES_QUANTITY to compare this FY vs Previous FY.  I want these totals to be filtered by the slicers but am having trouble creating the previous year.  The fiscal year is a single selection slicer only.

 

I managed to create the previous FY that works by ignoring the filters but it doesn't get sliced by the FISCAL_QUARTER, LOCATION_NAME.

 

Thanks in advance!

1 REPLY 1
Alef_Ricardo_
Resolver II
Resolver II

It sounds like you're trying to create a measure that calculates the sum of `SALES_QUANTITY` for the current fiscal year and the previous fiscal year, and have it be filtered by the slicers for `FISCAL_YEAR`, `FISCAL_QUARTER`, and `LOCATION_NAME`.

 

One way to achieve this is to create two measures: one for the current fiscal year and one for the previous fiscal year. The measure for the current fiscal year can be created using the `CALCULATE` function, which allows you to perform calculations within a specific filter context. Here's an example of what the measure for the current fiscal year might look like:

```
Current FY Sales =
CALCULATE(
SUM(SALES[SALES_QUANTITY]),
USERELATIONSHIP(SALES[FULFILL_DATE], DATE[DATE_DT])
)
```

This measure calculates the sum of `SALES_QUANTITY` from the `SALES` table, and uses the `USERELATIONSHIP` function to apply the relationship between the `FULFILL_DATE` column in the `SALES` table and the `DATE_DT` column in the `DATE` table.

 

 

The measure for the previous fiscal year can be created in a similar way, but with an additional filter to only include data from the previous fiscal year. Here's an example of what this measure might look like:

```
Previous FY Sales =
CALCULATE(
SUM(SALES[SALES_QUANTITY]),
USERELATIONSHIP(SALES[FULFILL_DATE], DATE[DATE_DT]),
DATEADD(DATE[DATE_DT], -1, YEAR)
)
```

This measure is similar to the measure for the current fiscal year, but it includes an additional filter using the `DATEADD` function to shift the dates in the `DATE_DT` column back by one year. This will effectively filter the data to only include sales from the previous fiscal year.

 

Once you have these two measures, you can use them in a visual or table to compare sales between the current and previous fiscal years. These measures should also respond to any slicers you have on your report page, allowing you to filter the data by `FISCAL_YEAR`, `FISCAL_QUARTER`, and `LOCATION_NAME`.

 

I hope this helps! Let me know if you have any questions or if there's anything else I can do to assist you. 😊

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.