Dax 中以逗号分隔值对项目进行分组

Group Items in Comma Separated values in Dax

我有以下 DAX 代码。我需要基于 Week No 的逗号分隔假期列表。我厌倦了 CONCATENATEX 函数,它将所有逗号分隔的假期列表组合在每一行中,而不是按周计算。任何人都知道我们如何使用 DAX 实现低于预期的目标。

Dax 代码:

DEFINE
VAR A = UNION(   ROW ("WeekNo",  1, "USAHoliday", "New Year", "CANHoliday","New Year")
                ,ROW ("WeekNo",  16, "USAHoliday", "Easter Sunday", "CANHoliday","Easter Sunday")
                ,ROW ("WeekNo",  16, "USAHoliday", "", "CANHoliday","Easter Monday")
                ,ROW ("WeekNo",  27,  "USAHoliday", "Independence Day", "CANHoliday","")
                ,ROW ("WeekNo",  28,  "USAHoliday", "", "CANHoliday","Independence Day")
                ,ROW ("WeekNo",  22,  "USAHoliday", "Memorial Day", "CANHoliday","")
            )

VAR AHoliday = DISTINCT(FILTER( UNION(SELECTCOLUMNS(A,
                        "WeekNo",[WeekNo]
                        ,"Holiday",[USAHoliday]
                        ),
                SELECTCOLUMNS(A,
                        "WeekNo",[WeekNo]
                        ,"Holiday",[CANHoliday]
                        )
                ),[Holiday]<>""))

VAR HolidayList=SUMMARIZE(AHoliday
            ,[WeekNo]
            ,"HolidayList.", CONCATENATEX(AHoliday,[Holiday],",", [Holiday],ASC)
            )
            
EVALUATE HolidayList

预期结果

HolidayList 应定义为,例如:

SUMMARIZE(
    AHoliday,
    [WeekNo],
    "HolidayList",
        CONCATENATEX(
            FILTER( AHoliday, [WeekNo] = EARLIER( [WeekNo] ) ),
            [Holiday],
            ", "
        )
)