Forum Discussion
amikm
Helper V
5 years agoIssue with Date during closed year
I have a table that has all the dates from 01/01/2020 to 31/12/2020 I am writing a DAX measure to calculate Sales based on dates Sales=CALCULATE(SUM(Sales[Sale]), FILTER(Sales,Sales[CYPY]="CY")) ...
Anonymous
5 years agoNot applicable
Hi amikm ,
You could use the following formula to modify the CYPY logic:
CYPY =
IF (
MONTH ( TODAY () ) > 1,
IF ( YEAR ( [Date] ) = YEAR ( TODAY () ) - 1, "PY", "CY" ),
IF (
YEAR ( [Date].[Date] )
= YEAR ( TODAY () ) - 1
&& MONTH ( [Date] ) = 12
|| YEAR ( [Date] ) = YEAR ( TODAY () ),
"CY",
"PY"
)
)
Here is the pbix file.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.