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.
Hi,
I currently have a slicer with Fiscal Year and a line graph with revenue/month.
However, whenever i select more than one Fiscal Year, the months group themselves together. As in, FY15 August and FY16 August are grouped together under August as one. This is understandable since they have the same month names.
However, when i select both years i want to see the effect over time and don't want them to group themselves.
As a solution i added FY behind every Month.
But this created Month ordering column to become very time consuming. I have to number every month of the year instead of just number 1-12. Is there a more efficient way of doing this?
Thanks,
Pamela
Solved! Go to Solution.
@Pammy2411 please see the linked .pbix file. Then check out the 3 steps in the query editor starting with "CC:". These are the custom columns i created using the code in my original post.
The line+bar combo graph is created using Fiscal Month and Fiscal Year along the X-axis. The chart is then Drilled Down to display the order you are looking for.
EDIT: ALSO, if you wish to display [Month] "Jan" "Feb" etc... in the visualization and still have the correct fiscal month sort applied, in the "Modeling" tab with the [Month] field selected from your fields list select "Sort this Column by" and then [Fiscal Month] to retain the fiscal month order.
M script:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VdCxCsIwGEXhV5HMHVS8DyCIQ0EdHEuHWoJLqUWM0LdvfzTJyVJuOYSEr2ncfrs7uMrV3bh+7Wdjs61SOftHLDZRLt07FpsoxykVm8WZOZ+ZWeqQXxDGsgy5DMU94ZnuWSfK3U+x2ES59Z9YbKJcX99YbKKcfB+LzX8R3UQ30U10E91EN9FNdBPdRDfRTXQT3UQ30U10E91EN9FNdBPdRDfRTT+3dgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Year = _t, Month = _t, #"Year + Month" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Month", type text}, {"Year + Month", type text}}),
#"CC: Month #" = Table.AddColumn(#"Changed Type", "Month #", each Date.Month(Date.From("1-"&[Month]&"-"&Text.From([Year])))),
#"CC: Fiscal Year" = Table.AddColumn(#"CC: Month #", "Fiscal Year", each Number.RoundDown([#"Month #"]/7)+[Year]),
#"CC: Fiscal Month" = Table.AddColumn(#"CC: Fiscal Year", "Fiscal Month", each if([#"Month #"]<7) then [#"Month #"]+6 else [#"Month #"]-6),
#"Changed Type1" = Table.TransformColumnTypes(#"CC: Fiscal Month",{{"Fiscal Month", Int64.Type}, {"Month #", Int64.Type}, {"Fiscal Year", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Fiscal Year", Order.Ascending}, {"Fiscal Month", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Value", 500, 1)
in
#"Added Index"
File:
@Pammy2411 'FY15 August' and 'FY16 August' have different names so if column is of type Text it should not group.
@Pammy2411 please see the linked .pbix file. Then check out the 3 steps in the query editor starting with "CC:". These are the custom columns i created using the code in my original post.
The line+bar combo graph is created using Fiscal Month and Fiscal Year along the X-axis. The chart is then Drilled Down to display the order you are looking for.
EDIT: ALSO, if you wish to display [Month] "Jan" "Feb" etc... in the visualization and still have the correct fiscal month sort applied, in the "Modeling" tab with the [Month] field selected from your fields list select "Sort this Column by" and then [Fiscal Month] to retain the fiscal month order.
M script:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VdCxCsIwGEXhV5HMHVS8DyCIQ0EdHEuHWoJLqUWM0LdvfzTJyVJuOYSEr2ncfrs7uMrV3bh+7Wdjs61SOftHLDZRLt07FpsoxykVm8WZOZ+ZWeqQXxDGsgy5DMU94ZnuWSfK3U+x2ES59Z9YbKJcX99YbKKcfB+LzX8R3UQ30U10E91EN9FNdBPdRDfRTXQT3UQ30U10E91EN9FNdBPdRDfRTT+3dgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Year = _t, Month = _t, #"Year + Month" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Month", type text}, {"Year + Month", type text}}),
#"CC: Month #" = Table.AddColumn(#"Changed Type", "Month #", each Date.Month(Date.From("1-"&[Month]&"-"&Text.From([Year])))),
#"CC: Fiscal Year" = Table.AddColumn(#"CC: Month #", "Fiscal Year", each Number.RoundDown([#"Month #"]/7)+[Year]),
#"CC: Fiscal Month" = Table.AddColumn(#"CC: Fiscal Year", "Fiscal Month", each if([#"Month #"]<7) then [#"Month #"]+6 else [#"Month #"]-6),
#"Changed Type1" = Table.TransformColumnTypes(#"CC: Fiscal Month",{{"Fiscal Month", Int64.Type}, {"Month #", Int64.Type}, {"Fiscal Year", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Fiscal Year", Order.Ascending}, {"Fiscal Month", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Value", 500, 1)
in
#"Added Index"
File:
@MarkDGaal Thank you for your sample code, but in my case the fiscal year starts at "April" and I can't mange to reuse your code, appreciate your support.
Assuming you have [Year] (eg. ####) and [Month] (eg. "Aug") in your table you can use M to derive the Month # in the following way.
= Table.AddColumn(#"NameofyourPreviousStep", "Month #",
each Date.Month(Date.From("1-"&[Month]&"-"&Text.From([Year]))))
If youre interested in calculating Fiscal Year with an October start check out this:
= Table.AddColumn(#"NameofYourPreviousStep", "FY", each Number.RoundDown([#"Month #"]/10)+[Year])
If youre interested in calculating Fiscal Month with an October start check out this:
= Table.AddColumn(#"NameofYourPreviousStep", "Fiscal Month",
each if([#"Month #"]<10) then [#"Month #"]+3 else [#"Month #"]-9)
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 |
---|---|
97 | |
96 | |
82 | |
74 | |
66 |
User | Count |
---|---|
121 | |
105 | |
102 | |
82 | |
72 |