在我的数据模型中,我有多年来不同销售事件的销售额。
我需要比较多个事件名称(图例)与月份名称(X 轴)的销售数量(Y 轴)。
如果我使用 RunningMonth,则每个 EventName 上的第一个订单将是几个月,visula 将起作用。
但我需要构建视觉效果以显示按 RunningMonth 排序的 MonthName,因为 SalesEvent 的时间可能会超过一年。然而,这不起作用,因为工具提示的排序由于自动求和而失败:
我已经尝试了一种在工具提示中进行排序的方法,就像我在其他帖子上发现的那样,但由于我的多个 EventNames,它似乎不起作用:
Sorter =
SWITCH( VALUES(Orders[SortABC]),
"1",1,
"2",2,
"3",3,
"4",4,
"5",5,
"6",6,
"7",7,
"8",8,
"9",9,
"10",10,
"11",11,
"12",12,
"13",13,
"14",14,
"15",15,
"16",16,
17
)
这是示例数据,如果有人可以帮助我的话。
with upa as
(
select 'Sales19' as EventName, 1 as RunningMonth, cast('28.11.2019' as Date) as CreatedOn, 100 as Quantity union all
select 'Sales19' as EventName, 2 as RunningMonth, cast('31.12.2019' as Date) as CreatedOn, 200 as Quantity union all
select 'Sales19' as EventName, 3 as RunningMonth, cast('02.02.2020' as Date) as CreatedOn, 150 as Quantity union all
select 'Sales19' as EventName, 4 as RunningMonth, cast('06.03.2020' as Date) as CreatedOn, 70 as Quantity union all
select 'Sales19' as EventName, 5 as RunningMonth, cast('08.04.2020' as Date) as CreatedOn, 50 as Quantity union all
select 'Sales19' as EventName, 6 as RunningMonth, cast('11.05.2020' as Date) as CreatedOn, 40 as Quantity union all
select 'Sales19' as EventName, 7 as RunningMonth, cast('13.06.2020' as Date) as CreatedOn, 20 as Quantity union all
select 'Sales19' as EventName, 8 as RunningMonth, cast('16.07.2020' as Date) as CreatedOn, 30 as Quantity union all
select 'Sales19' as EventName, 9 as RunningMonth, cast('18.08.2020' as Date) as CreatedOn, 8 as Quantity union all
select 'Sales19' as EventName, 10 as RunningMonth, cast('20.09.2020' as Date) as CreatedOn, -12 as Quantity union all
select 'Sales19' as EventName, 11 as RunningMonth, cast('23.10.2020' as Date) as CreatedOn, -20 as Quantity union all
select 'Sales19' as EventName, 12 as RunningMonth, cast('25.11.2020' as Date) as CreatedOn, 5 as Quantity union all
select 'Sales19' as EventName, 13 as RunningMonth, cast('28.12.2020' as Date) as CreatedOn, 0 as Quantity union all
select 'Sales19' as EventName, 14 as RunningMonth, cast('30.01.2021' as Date) as CreatedOn, 0 as Quantity union all
select 'Sales19' as EventName, 16 as RunningMonth, cast('04.03.2021' as Date) as CreatedOn, -4 as Quantity union all
select 'Sales23' as EventName, 1 as RunningMonth, cast('02.12.2023' as Date) as CreatedOn, 125 as Quantity union all
select 'Sales23' as EventName, 2 as RunningMonth, cast('07.01.2024' as Date) as CreatedOn, 250 as Quantity union all
select 'Sales23' as EventName, 3 as RunningMonth, cast('12.02.2024' as Date) as CreatedOn, 187 as Quantity union all
select 'Sales23' as EventName, 4 as RunningMonth, cast('19.03.2024' as Date) as CreatedOn, 87 as Quantity union all
select 'Sales23' as EventName, 5 as RunningMonth, cast('24.04.2024' as Date) as CreatedOn, 62 as Quantity union all
select 'Sales23' as EventName, 6 as RunningMonth, cast('30.05.2024' as Date) as CreatedOn, 50 as Quantity union all
select 'Sales23' as EventName, 7 as RunningMonth, cast('05.07.2024' as Date) as CreatedOn, 25 as Quantity union all
select 'Sales23' as EventName, 8 as RunningMonth, cast('10.08.2024' as Date) as CreatedOn, 37 as Quantity union all
select 'Sales23' as EventName, 9 as RunningMonth, cast('15.09.2024' as Date) as CreatedOn, 10 as Quantity union all
select 'Sales23' as EventName, 10 as RunningMonth, cast('21.10.2024' as Date) as CreatedOn, -15 as Quantity union all
select 'Sales23' as EventName, 11 as RunningMonth, cast('26.11.2024' as Date) as CreatedOn, -25 as Quantity union all
select 'Sales23' as EventName, 13 as RunningMonth, cast('01.01.2025' as Date) as CreatedOn, 6 as Quantity union all
select 'Sales23' as EventName, 14 as RunningMonth, cast('06.02.2025' as Date) as CreatedOn, 0 as Quantity union all
select 'Sales23' as EventName, 15 as RunningMonth, cast('14.03.2025' as Date) as CreatedOn, 0 as Quantity
)
select * from upa
请帮忙。
您的样本数据中存在一些漏洞 - 例如,
Sales19
缺少 Jan,而 RunningMonth
2 到 3 之间。
有几个选项。
为 RunningMonth 创建一个新的度量,它将连接重叠的月份。
RunningMonth txt = CONCATENATEX(Orders, FORMAT([RunningMonth], "00"), ", ")
使用它作为图表工具提示并像以前一样排序。该图表将根据第一个 EventName 对月份进行排序。此选项的一个好处是,如果用户选择 EventName(切片器或交叉突出显示),月份将根据它重新排序。
第二个选项是为月份数创建一个计算列:
MonthNum = MONTH([CreatedOn])
然后选择“月份”列和
Sort by column
上的 MonthNum
。完成后,按轴月对图表进行排序。