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 September 15. Request your voucher.
I am trying to calculate the % of days elapsed since the beginning of a custom fiscal 4 week period. I have a date table with date, week in year, fiscal week, is current week etc. In another post someone suggested adding a new column that would return the first day of the current fiscal period, but when I usethe datediff function it returns elapsed days such as 1,878 rather than 4-25-19 minus 4-20-19 = 5
first day per period = CALCULATE ( MIN ( [Date] ), ALLEXCEPT ( 'Table', 'Table'[Fiscal period] ) )
Solved! Go to Solution.
hi, @jpt1228
"I think the problem is the IsCurrentFiscalPeriod repeats every year as True rather than just the current fiscal period in the current year."
This should be the reason for the problem, So just add a conditional in the formula:
Column = IF ( 'Date'[IsCurrentFiscalPeriod] = TRUE () && 'Date'[Year] = YEAR ( TODAY () ), DATEDIFF ( CALCULATE ( MIN ( 'Date'[Date Short] ), FILTER ( 'Date', 'Date'[IsCurrentFiscalPeriod] = TRUE () && 'Date'[Year] = YEAR ( TODAY () ) ) ), 'Date'[Date Short], DAY ) )
Best Regards,
Lin
hi, @jpt1228
What is your expected output?
datediff(3/23/2014 , today(), day) is right, why it should be 4-25-19 minus 4-20-19 = 5
I didn't see 4-25-19 or 4-20-19 in the screenshot.
Best Regards,
Lin
Hi @v-lili6-msft I was using those 2 dates as an example. Given the below date table it appears that the fiscal period start date is correct for the month/day but incorrect for the year. I would like the Date Short highlighted 5-23-19 to show how many days have elapsed since the first day of the fiscal period which started on 5-19-19.
5-23-19 minus 5-19-19 = 4. On 5-24-19 the calculation would be 5-24-19 minus 5-19-19 = 5.
hi, @jpt1228
Sorry for the late reply, Try this formula to create a column
Column = IF('Date'[IsCurrentFiscalPeriod]=TRUE(),DATEDIFF(CALCULATE(MIN('Date'[Date Short]),FILTER('Date','Date'[IsCurrentFiscalPeriod]=TRUE())),'Date'[Date Short],DAY))
OR
Column 2 = IF('Date'[IsCurrentFiscalPeriod]=TRUE()&&'Date'[Date Short]>=TODAY(),DATEDIFF(CALCULATE(MIN('Date'[Date Short]),FILTER('Date','Date'[IsCurrentFiscalPeriod]=TRUE())),'Date'[Date Short],DAY))
Result:
Best Regards,
Lin
Hello @v-lili6-msft - I created a column as suggested but not getting the desired result. The Min date in the table starts in year 2014.
I think the problem is the IsCurrentFiscalPeriod repeats every year as True rather than just the current fiscal period in the current year.
the column formula for IsCurrentFiscalPeriod is:
hi, @jpt1228
"I think the problem is the IsCurrentFiscalPeriod repeats every year as True rather than just the current fiscal period in the current year."
This should be the reason for the problem, So just add a conditional in the formula:
Column = IF ( 'Date'[IsCurrentFiscalPeriod] = TRUE () && 'Date'[Year] = YEAR ( TODAY () ), DATEDIFF ( CALCULATE ( MIN ( 'Date'[Date Short] ), FILTER ( 'Date', 'Date'[IsCurrentFiscalPeriod] = TRUE () && 'Date'[Year] = YEAR ( TODAY () ) ) ), 'Date'[Date Short], DAY ) )
Best Regards,
Lin
User | Count |
---|---|
69 | |
69 | |
66 | |
54 | |
28 |
User | Count |
---|---|
112 | |
82 | |
66 | |
48 | |
43 |