Forum Discussion
Wrong total values
Do you have a Date Dimension? Is it tied to your fact data on the Date? If not, let's start there.
Create a table with this:
My Dates = CALENDAR("01/01/2020", "12/31/2024")
Add to that a calculated column:
Year = YEAR ( 'My Dates'[Date] )
Create a relationship from the Dates table to the fact table.
Create some Measures m(in the fact table:
Total Quantity = SUM( [Sale Quantity] )
Total Sales Amount = SUM( [Sale Amount] )
Sale Price = DIVIDE ( [Total Sales Amount], [Total Quantity], 0 )
Total Quantity LAST YEAR = CALCULATE ( [Total Quantity], SAMEPERIODLASTYEAR ('My Dates'[Date] ) )
Total Sales Amount LAST YEAR = CALCULATE...<I think you can figure this one out, yes?>
Sale Price LAST YEAR = DIVIDE ( <yeah, I think you got this one too! > )
Now set up a Table Visual and add 'My Dates'[Year], then add all the above measures.
To prove it works, look at, say [Total Quantity LAST YEAR] for 2022 and compare it to [Total Quantity] of 2021. It should exactly match.
Now for the climax, create a measure:
My Increase or Decrease = ([Sale Price] - [Sale Price LAST YEAR] ) * [Total Quantity]
Add that as maybe a card visual, and FILTER the data for THIS YEAR, or use a Relative Date Slicer.
Hope that helps.
- MikeUS3 years agoHelper I
Hi, thanks for the step-by-step guide - really appreciate!!
made a screenshot of the real data and hope you can read that ?
Problem: the total amount per year is not correct
Correct is 5443 on line level
Total 6998 aggregate isnt correct