Forum Discussion

bmurf's avatar
bmurf
Frequent Visitor
5 years ago
Solved

Summarize Table and Sum duplicates ids

I have two tables "Donor" and "Giving" (see below) joined by [user_id] that are used to generate a 3rd table for export.     The Requirements: 1) Calculate total [amount] given by [family_id] 2) ...
  • edhans's avatar
    edhans
    5 years ago

    I'm not typing all of my stuff again. in summary, i changed roger to 12, but there is no donor data in 12 so nothign shows up.

    Donors =
    VAR varCurrentFamily =
        SUMMARIZE(
            'Donor Table',
            'Donor Table'[family_id  ],
            'Donor Table'[user_id  ],
            'Donor Table'[Marital Status]
        )
    VAR varMemberCount =
        COUNTROWS( varCurrentFamily )
    VAR varValidDonors =
        IF(
            varMemberCount > 2,
            CONCATENATEX(
                CALCULATETABLE(
                    'Donor Table',
                    'Donor Table'[Marital Status] = "Married"
                ),
                [first_name       ],
                ", ",
                [first_name       ], ASC
            ),
            CONCATENATEX(
                'Donor Table',
                'Donor Table'[first_name       ],
                ", ",
                'Donor Table'[first_name       ], ASC
            )
        )
    RETURN
        IF(
            ISINSCOPE( 'Donor Table'[family_id  ] )
                && [Total Giving]
                    <> BLANK(),
            varValidDonors,
            BLANK()
        )
    

    This measure will look for families with more than 2. If it finds that, it only pulls married, otherwise it does the normal stuff. the PBIX file I linked to above can be used again. It has this new code. There is probably a more efficient way to do this, but this works.