Forum Discussion
Weird Previousmonth behavior
- 7 years ago
Hi Anonymous ,
In your scenario, we cannot use previousmonth or dateadd. As for both fucntion, we can get the date by the current row, However in a card visual, there is no filter like a table visual. That's why we got incorrect result by that way. So we can use EDATE to work on it that the logic is slmilar to your work around.
previous = VAR a = FORMAT ( EDATE ( TODAY (), -1 ), "yyyymmm" ) RETURN CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmm" ) = a ) )
Thank you very much for the reply, I see it works like a charm.
I think it was a misunderstanding from my part: I wanted to show the amount belonging to the previous month on a Card visual (last month's count). In your example, using the measure in a card visual also returns a blank.
How do I incorporate these measures in a card visual? So that one amount (that of the last month) is shown?
Hi Anonymous ,
In your scenario, we cannot use previousmonth or dateadd. As for both fucntion, we can get the date by the current row, However in a card visual, there is no filter like a table visual. That's why we got incorrect result by that way. So we can use EDATE to work on it that the logic is slmilar to your work around.
previous =
VAR a =
FORMAT ( EDATE ( TODAY (), -1 ), "yyyymmm" )
RETURN
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmm" ) = a )
)