The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a date field app_date and I want to create 2 additional colums
YTD flag 1 or 0
PYTD flag 1 or 0
Can someone please help with the correct dax?
Solved! Go to Solution.
Is in current year to date?
you can check if the year is the same. This is the dax measure:
YTD = IF(YEAR('YourTable'[app_date]) = YEAR(TODAY()), 1, 0)
YTDPY = IF(YEAR('YourTable'[app_date]) = YEAR(TODAY()) - 1, 1, 0)
Hi @M_SBS_6
Thanks for the reply from @Gabry , please allow me to provide another insight:
Maybe you can try this:
I create a simple table, it contains two dates.
Then I create two measures to satisfy your requirements.
YTD Flag =
IF ( TOTALYTD ( SUM ( 'Table'[app_date] ), 'Table'[app_date] ) > 0, 1, 0 )
PYTD Flag =
IF (
TOTALYTD ( SUM ( 'Table'[app_date] ), SAMEPERIODLASTYEAR ( 'Table'[app_date] ) ) > 0,1,0
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @M_SBS_6
Thanks for the reply from @Gabry , please allow me to provide another insight:
Maybe you can try this:
I create a simple table, it contains two dates.
Then I create two measures to satisfy your requirements.
YTD Flag =
IF ( TOTALYTD ( SUM ( 'Table'[app_date] ), 'Table'[app_date] ) > 0, 1, 0 )
PYTD Flag =
IF (
TOTALYTD ( SUM ( 'Table'[app_date] ), SAMEPERIODLASTYEAR ( 'Table'[app_date] ) ) > 0,1,0
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi EML,
please explain a little better.
What flag 1 or 0 means?
I can't understand what you want to do
If a date is in the current year to date then flag as 1. If it's not in the current year to date, flag as 0.
Same principle for previous year to date
Is in current year to date?
you can check if the year is the same. This is the dax measure:
YTD = IF(YEAR('YourTable'[app_date]) = YEAR(TODAY()), 1, 0)
YTDPY = IF(YEAR('YourTable'[app_date]) = YEAR(TODAY()) - 1, 1, 0)
User | Count |
---|---|
81 | |
74 | |
42 | |
30 | |
28 |
User | Count |
---|---|
108 | |
96 | |
53 | |
48 | |
47 |