Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all,
Slightly long question here so I appreciate your time!!
I am trying to create a variance % column to show the change in revenue from last year to this year in a table. In order to do so, I first need a measure that calculates previous year revenue using FISCAL dates, not actual dates. Our company uses the 445 Fiscal Calendar so the first and second month of each quarter have 4 weeks, and the third month of the quarter has 5 weeks. For this reason, I'm not sure how to create a continuous date column that corresponds to the fiscal date criteria needed. Instead, I tried for the next best thing to continous and created a column for Month-Year in my date table and sales table. To get the previous year revenue, I found online that i needed to use the sameperiodlastyear function, but that doesn't seem to work with my column that's formatted as Month-Year. For context, Here is what my date table looks like:
I've made sure to mark this table as my date table but I used the Date (Actual) column in the picture to create that distinction. As for my data relationships, below is a picture of how I connected my date table to my sales table using a many to many relationship via the Month-Year column shown above.
The problem is that when I make my DAX expression for PY Revenue as so:
Solved! Go to Solution.
Hi @dbarseg1 -I hope in your date table fiscal year, fiscal month is exist,if not below is the code added and then create a custom calculation as like below to shift the dates according to your fiscal calendar.
"FiscalYear", IF(MONTH([Date]) >= 4, YEAR([Date]), YEAR([Date])-1)
FiscalMonth",
IF (
MONTH([Date]) >= 4,
MONTH([Date]) - 3,
MONTH([Date]) + 9
PY revenue calculation as below:
PY Revenue =
CALCULATE(
[Total Revenue],
FILTER (
ALL ( 'DateTable' ),
'DateTable'[FiscalYear] = MAX ( 'DateTable'[FiscalYear] ) - 1 &&
'DateTable'[FiscalMonth] = MAX ( 'DateTable'[FiscalMonth] )
)
)
This calculation filters the date table to the same fiscal month of the previous FY
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Hi @dbarseg1 -I hope in your date table fiscal year, fiscal month is exist,if not below is the code added and then create a custom calculation as like below to shift the dates according to your fiscal calendar.
"FiscalYear", IF(MONTH([Date]) >= 4, YEAR([Date]), YEAR([Date])-1)
FiscalMonth",
IF (
MONTH([Date]) >= 4,
MONTH([Date]) - 3,
MONTH([Date]) + 9
PY revenue calculation as below:
PY Revenue =
CALCULATE(
[Total Revenue],
FILTER (
ALL ( 'DateTable' ),
'DateTable'[FiscalYear] = MAX ( 'DateTable'[FiscalYear] ) - 1 &&
'DateTable'[FiscalMonth] = MAX ( 'DateTable'[FiscalMonth] )
)
)
This calculation filters the date table to the same fiscal month of the previous FY
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Thank you so much!!
I've been stuck on this for so long. I used your logic with Chat GPT to ensure that all my date hierarchy in the matrix show prior year. Here it is in case others want to reference an expanded version of your code:
User | Count |
---|---|
84 | |
80 | |
70 | |
47 | |
43 |
User | Count |
---|---|
108 | |
54 | |
50 | |
40 | |
40 |