Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
i want to display data Current month and last month ,by using cal.month/yeat after two years month data will be like 2021/01,2021,02.....2022/01,2022,02
,
But data should be(Month) like below but i write code it is not working
Solved! Go to Solution.
Hi @Anonymous,
Did you mean the formula would calculate based on the last date in your table instead of dynamic system date? If that is the case, you can add a variable to extract the 'last date' and use it as a condition to calculate in the if statement.
Month Tag =
VAR _lastDate =
MAXX ( Table, [Date] )
RETURN
IF (
EOMONTH ( [Date], 0 ) = EOMONTH ( _lastDate, -1 ),
"Last Month",
IF (
EOMONTH ( [Date], 0 ) = EOMONTH ( _lastDate, 0 ),
"Current Month",
FORMAT ( _lastDate, "YYYY/MM" )
)
)
Regards,
Xiaoxin Sheng
@Anonymous , Create a new column like
Month Type = Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"Current Month" ,
Format([Date],"YYYY/MM")
)
Hi amitchandak,
Thanks for your supporting as per requirement coding is working
but as per my requirement i want display current month and last mont for ex. i have a data in my table i will see report after one year so then at that time my new filed sholud show the current month(01/2022,02/2022) and last month (11/2021,12/2021) like below pic
means cal.year/month data is like below
01/2020
02/2021
our new table after write coding (after one year table data should like below)
2021/01(last month)
2021/02
2022/01(Current month)
2022/01
Hi @Anonymous,
Did you mean the formula would calculate based on the last date in your table instead of dynamic system date? If that is the case, you can add a variable to extract the 'last date' and use it as a condition to calculate in the if statement.
Month Tag =
VAR _lastDate =
MAXX ( Table, [Date] )
RETURN
IF (
EOMONTH ( [Date], 0 ) = EOMONTH ( _lastDate, -1 ),
"Last Month",
IF (
EOMONTH ( [Date], 0 ) = EOMONTH ( _lastDate, 0 ),
"Current Month",
FORMAT ( _lastDate, "YYYY/MM" )
)
)
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
148 | |
116 | |
104 | |
89 | |
65 |