March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello Team,
I have date column of text format where values will be like 2017.12, 2018.01, 2018.12...I want to create a report for which I need to show last 12 months of data only. How can we achieve this requirement to change the values according to current date dynamically?
Ex:
Current Month: Aug 2018
Requied report data: Aug 2017 - Jul 2018 (2017.08 - 2018.07 column)
Current Month: Mar 2018
Requied report data: Mar 2017 - Feb 2018 (2017.03 - 2018.02 column)
Thanks in advance.
Regards,
Shiva
Solved! Go to Solution.
For current month, you may try below measure:
Measure = VAR a = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 ) RETURN IF ( MAX ( 'Table'[YearMonth.No] ) IN DATESINPERIOD ( 'Table'[YearMonth.No], a, -12, MONTH ), 1 )
Regards,
Cherie
You may try to add a column to format the text column to date column as below:
YearMonth.No = DATE ( LEFT ( 'Table'[YearMonth], 4 ), RIGHT ( 'Table'[YearMonth], 2 ), 1 )
Then create a measure as requested. For example:
MonthSelect = VAR a = DATE ( YEAR ( SELECTEDVALUE ( 'Current'[Current Month] ) ), MONTH ( SELECTEDVALUE ( 'Current'[Current Month] ) ) - 1, 1 ) RETURN IF ( MAX ( 'Table'[YearMonth.No] ) IN DATESINPERIOD ( 'Table'[YearMonth.No], a, -12, MONTH ), 1 )
Regards,
Cherie
Thanks you @v-cherch-msft
But we don't have any filter to select current month. It should be change based on the current date.
Regards,
Shiva
For current month, you may try below measure:
Measure = VAR a = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 ) RETURN IF ( MAX ( 'Table'[YearMonth.No] ) IN DATESINPERIOD ( 'Table'[YearMonth.No], a, -12, MONTH ), 1 )
Regards,
Cherie
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |