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 am creating a calculated column
i have mtd ,ytd qtd mtd today -1 i want IF A NEW YEAR STARTS THEN MTD SHOULD SHOW LAST MONTH 1 ST TO 31SR AND SAME LIKE QTD WHEN NEW QUATER STARTS SAME PERVOIUS QUATER TO START TILL 31SR DEC ,SAME LIKE YTD IF DAY =1 JAN JAN 1ST 2025 A NEW YEAR START YTS ALSO SOULD SHOW 1 JAN 2024 TO 31-DEC-2024
ANY ONE HELP ME
Solved! Go to Solution.
Hi @Anonymous ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Create the new measure to calculate MTD. Drag the measure into the Filter and edit the items is 1.
MTD =
VAR start_month = EOMONTH(DATE(2025,1,1), -2) + 1
var end_month = EOMONTH(DATE(2025,1,1), -1)
RETURN
IF(MONTH(MAX([Date])) = 12, 1, 0
)
3.Create the new measure to calculate YTD. Drag the measure into the Filter and edit the items is 1.
YTD =
var year_start = DATE(YEAR(2025) - 1, 1, 1)
VAR year_end = DATE(YEAR(2025) - 1, 12, 31)
RETURN
IF(YEAR(MAX(DateTable[Date])) = 2024, 1, 0)
4.Create the new measure to calculate QTD. Drag the measure into the Filter and edit the items is 1.
QTD =
VAR current_quarter = QUARTER(1)
VAR end_month = IF(current_quarter = 1, 12, (current_quarter - 1) * 3)
VAR start_month = end_month - 2
RETURN
IF(QUARTER(MAX(DateTable[Date])) = 4, 1, 0)
5.The result is shown below for MTD.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Create the new measure to calculate MTD. Drag the measure into the Filter and edit the items is 1.
MTD =
VAR start_month = EOMONTH(DATE(2025,1,1), -2) + 1
var end_month = EOMONTH(DATE(2025,1,1), -1)
RETURN
IF(MONTH(MAX([Date])) = 12, 1, 0
)
3.Create the new measure to calculate YTD. Drag the measure into the Filter and edit the items is 1.
YTD =
var year_start = DATE(YEAR(2025) - 1, 1, 1)
VAR year_end = DATE(YEAR(2025) - 1, 12, 31)
RETURN
IF(YEAR(MAX(DateTable[Date])) = 2024, 1, 0)
4.Create the new measure to calculate QTD. Drag the measure into the Filter and edit the items is 1.
QTD =
VAR current_quarter = QUARTER(1)
VAR end_month = IF(current_quarter = 1, 12, (current_quarter - 1) * 3)
VAR start_month = end_month - 2
RETURN
IF(QUARTER(MAX(DateTable[Date])) = 4, 1, 0)
5.The result is shown below for MTD.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
have several time-based metrics such as MTD (Month-to-Date), YTD (Year-to-Date), and QTD (Quarter-to-Date). For the MTD calculation, I want it to show data from the 1st to the last day of the previous month if the current date is the 1st day of a new year. Similarly, for QTD, I need it to display data from the start of the previous quarter until December 31st if a new quarter starts. Additionally, for YTD, when it's January 1st of a new year, I'd like it to show data from January 1st of the previous year to December 31st of the previous year.
Could you please assist me in rewriting the logic for this calculated column?
Thank you very much for your help!
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 |
---|---|
95 | |
94 | |
80 | |
71 | |
64 |
User | Count |
---|---|
115 | |
106 | |
96 | |
81 | |
72 |