Forum Discussion
Anonymous
5 years agoNot applicable
Previous Year Sales issue
Hi Experts See attatched PBIX and the PY measure is in the FACT Sales Table. I am unable to get the previous years sales, if i do its the same value as the current year sales (i.e. 2020) Samp...
- 5 years ago
You don't get what you want because your calendar is screwed up. Also, it's not marked as a date table.
Here are your measures for when you fix your calendar:
USD = SWITCH ( SELECTEDVALUE ( DimHierarchy[AccountItem] ), "Gross Sales", SUM ( FACTSales[Gross Sales (USD)] ), "Rebate", SUM ( FACTSales[Rebate (USD)] ), "Net Sales", SUM ( FACTSales[Net Sales (USD)] ) )and
PY = IF( HASONEVALUE( DimDate[Year] ), CALCULATE( [USD], SAMEPERIODLASTYEAR( DimDate[Date] ) ) )Measures should never be defined in more than 1 place. Duplication of code is a sign of a bad design and the root of all evil in programming.
daxer-almighty
5 years agoSolution Sage
You don't get what you want because your calendar is screwed up. Also, it's not marked as a date table.
Here are your measures for when you fix your calendar:
USD =
SWITCH ( SELECTEDVALUE ( DimHierarchy[AccountItem] ),
"Gross Sales", SUM ( FACTSales[Gross Sales (USD)] ),
"Rebate", SUM ( FACTSales[Rebate (USD)] ),
"Net Sales", SUM ( FACTSales[Net Sales (USD)] )
)
and
PY =
IF( HASONEVALUE( DimDate[Year] ),
CALCULATE(
[USD],
SAMEPERIODLASTYEAR( DimDate[Date] )
)
)
Measures should never be defined in more than 1 place. Duplication of code is a sign of a bad design and the root of all evil in programming.
- Anonymous5 years agoNot applicable
When you say calender is messed up what do you mean. can you tell me steps to correct it..
- daxer-almighty5 years agoSolution Sage