The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
I am trying to get an answer googling around but could not find it so was hoping for your help.
I have a date table with calendar and fiscal years and months.
Anyway I would also need to create new column within the date table called "FinancialMonth". Financial months are not starting from 1st of the month and ending 31st of the month but instead are as follows:
Thank you a lot for your help.
Best regards
If I had known you were going to be formatting it as a date, I might have tried something like this.
_Fiscal Period 2 =
VAR _Start = EOMONTH( [Date], -2 ) + 16
VAR _End = EOMONTH( [Date], -1 ) + 15
VAR _Next = EOMONTH( [Date], 0 ) + 1
VAR _Prev = EOMONTH( [Date], -1 ) + 1
VAR _Result =
IF(
[Date] >= _Start
&& [Date] <= _End,
_Prev,
_Next
)
RETURN
_Result
Again, since it returns a date instead of a string, it will sort automatically.
Hi, @JgreatX
i have a question
feb contain 28(29 sometime) days so how feb fit 30 days in 28 days?
as your requirnment
Hi @JgreatX
Would a calculated column (in your Date table) like this help?
Fiscal Period =
VAR _Start = EOMONTH( [Date], -2 ) + 16
VAR _End = EOMONTH( [Date], -1 ) + 15
VAR _StYear = YEAR( _Start )
VAR _Text1 = FORMAT( _Start, "mmmm" ) & " " & _StYear
VAR _Text2 = FORMAT( _End, "mmmm" ) & " " & [Year]
VAR _Result =
IF(
[Date] >= _Start
&& [Date] <= _End,
_Text1,
_Text2
)
RETURN
_Result
Let me know if you have any questions.
Thanks a lot,
I think I am very close now, the only issue now i see is when i want to present results within a fiscal year. I was wondering if you could help me adjust the code so that Financial Month period would be as follows (to fit fiscal year reporting that is from 1st July to 30th June)
Financial Month period (adjusted):
Thank you a lot in advance.
Best regards
Just fyi my calendar table looks like this now:
Hi @JgreatX
If you want, those columns can be added as calculated columns instead of including the code for those columns in the create table statement.
It's a matter of personal preference but I think having them separate makes the code look cleaner.
Thanks mgsamborn a lot for your help,
Just fyi in order for Financial Month period to show correctly as per my innitial instructions above i needed to slightly twick the code. Maybe is not the cleanest one but it is working:
Finance Period=
Hi mgsamborn,
Would you be able to give me a tip how to write sort column based on the latest formula above.
Thanks a lot,
BR
Thanks a lot,
Best regards
Hi @JgreatX
It looks like your column is returning a date in text format. If you change the Data type to Date (in Column Tools, not the column definition), it should sort itself regardless of format chosen.
Here is my example. (My sorting is different.)
Also, the reason I had a separate sort column was because Jan-24, Feb-24, Mar-24 don't automatically sort. You don't have that problem.
Let me know if you have any questions.
You would probably need a column to sort by.
Sort Fiscal Period =
VAR _Start = EOMONTH( [Date], -2 ) + 16
VAR _End = EOMONTH( [Date], -1 ) + 15
VAR _Next = EOMONTH( [Date], 0 ) + 1
VAR _Var1 = ( YEAR( _Next ) * 100 ) + MONTH( _Next )
VAR _Var2 = ( [Year] * 100 ) + MONTH( _End )
VAR _Result =
IF(
[Date] >= _Start
&& [Date] <= _End,
_Var2,
_Var1
)
RETURN
_Result
Not sure what would that column be but above solution looked very close what i am looking for, thanks again
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |