Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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_ID | LOCATION_NAME | SELLING_CURRENCY_CODE | STATUS |
1 | Store 1 | CAD | Active |
2 | Store 2 | USD | Active |
3 | Store 3 | USD | Active |
4 | Store 4 | CAD | Active |
5 | Store 5 | USD | Active |
DATE
DATE_DT | FISCAL_QUARTER_SHORT_NAME | FISCAL_YEAR_ID | FISCAL_WEEK |
1/1/2022 | Q4 | 2021 | 48 |
3/27/2021 | Q1 | 2021 | 8 |
8/8/2021 | Q3 | 2021 | 27 |
12/25/2021 | Q4 | 2021 | 47 |
4/28/2022 | Q1 | 2022 | 13 |
3/25/2021 | Q1 | 2021 | 8 |
6/19/2022 | Q2 | 2022 | 20 |
SALES
FULFILL_DATE | LOCATION_ID | SALES_QUANTITY |
1/1/2021 | 32 | 15 |
1/1/2021 | 1 | 14 |
1/1/2021 | 39 | 14 |
1/1/2021 | 38 | 12 |
1/1/2021 | 39 | 13 |
1/1/2021 | 39 | 11 |
1/1/2021 | 38 | 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!
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. 😊
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
20 | |
18 | |
17 | |
16 |
User | Count |
---|---|
38 | |
25 | |
18 | |
17 | |
13 |