Forum Discussion

cosminc's avatar
cosminc
Post Partisan
7 years ago
Solved

Insert custom rows

Hi all,

is it posible to add rows in a base like this:

 

IDYearMonthClientLabelValueconcatenate ID&Client
120181cosminA11cosmin
120181cosminB11cosmin
120181cosminC11cosmin
120181cosminD01cosmin
220182cosminA02cosmin
220182cosminB12cosmin
220182cosminC12cosmin
220182cosminD02cosmin
320181anaA03ana
320181anaB03ana
320181anaC03ana
320181anaD13ana
420183anaA04ana
420183anaB14ana
420183anaC14ana
420183anaD14ana
add custom rows     
120181cosminZ01cosmin
220182cosminZ02cosmin
320181anaZ03ana
420183anaZ14ana
If(Value for C=1 ann D=1 --value for new row is 1, otherwise os 0

 

the real base has thousands of rows and need to make something for each ID&Client

any idea?

Thanks,

Cosmin

 

  • Hi COSMINC,

    You could try to new custom row table by DAX like below

     

    custom rows =
    SUMMARIZE (
        cutsom,
        cutsom[ID],
        cutsom[Year],
        cutsom[Month],
        cutsom[client],
        cutsom[concatenate ID&Client],
        "value", IF (
            CALCULATE (
                SUM ( cutsom[Value] ),
                FILTER (
                    ALLEXCEPT ( cutsom, cutsom[ID] ),
                    cutsom[Label] = "C"
                        || cutsom[Label] = "D"
                )
            ) = 2,
            1,
            0
        ),
        "Label", "Z"
    )

    Then  use selectcolumn  and union syntax to combine two table like below

    Table 2 =
    UNION (
        cutsom,
        SELECTCOLUMNS (
            'custom rows',
            "id", 'custom rows'[ID],
            "year", 'custom rows'[Year],
            "Month", 'custom rows'[Month],
            "client", 'custom rows'[client],
            "lable", 'custom rows'[Label],
            "value", 'custom rows'[value],
            "con", 'custom rows'[concatenate ID&Client]
        )
    )

    Best Regards,

    Zoe Zhi

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • dax's avatar
    dax
    Community Support

    Hi COSMINC,

    You could try to new custom row table by DAX like below

     

    custom rows =
    SUMMARIZE (
        cutsom,
        cutsom[ID],
        cutsom[Year],
        cutsom[Month],
        cutsom[client],
        cutsom[concatenate ID&Client],
        "value", IF (
            CALCULATE (
                SUM ( cutsom[Value] ),
                FILTER (
                    ALLEXCEPT ( cutsom, cutsom[ID] ),
                    cutsom[Label] = "C"
                        || cutsom[Label] = "D"
                )
            ) = 2,
            1,
            0
        ),
        "Label", "Z"
    )

    Then  use selectcolumn  and union syntax to combine two table like below

    Table 2 =
    UNION (
        cutsom,
        SELECTCOLUMNS (
            'custom rows',
            "id", 'custom rows'[ID],
            "year", 'custom rows'[Year],
            "Month", 'custom rows'[Month],
            "client", 'custom rows'[client],
            "lable", 'custom rows'[Label],
            "value", 'custom rows'[value],
            "con", 'custom rows'[concatenate ID&Client]
        )
    )

    Best Regards,

    Zoe Zhi

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.