Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
RyanHare92
Helper I
Helper I

Referencing columns created with ADDCOLUMN in CALCULATE

This is something that I have struggled with many times in the past and I still quite wrap my head around how to resolve.

This is what I have put together:

EVALUATE

VAR _Working_Table = 
    ADDCOLUMNS(
        Current_Entries,
        "Concatenation", [centre] & [ass_code] & [com_id],
        "Absent_Ind", RELATED(Current_Active_Marks[absent])
    )

VAR _Summarized_Table = 
    SUMMARIZE(
        _Working_Table,
        [Concatenation]
    )
    
VAR _Added_Columns = 
    ADDCOLUMNS(
        _Summarized_Table,
        "Total_Cands", 
        CALCULATE(
            COUNTROWS(_Working_Table),
            FILTER(
                _Working_Table,
                _Working_Table[Concatenation] = EARLIER([Concatenation])
            )
        ),
        "Absent_Count", 
        CALCULATE(
            COUNTROWS(_Working_Table),
            FILTER(
                _Working_Table,
                _Working_Table[Concatenation] = EARLIER([Concatenation]) &&
                _Working_Table[Absent_Ind] = "A"
            )
        )
    )

VAR _Absent_Count = 
    ADDCOLUMNS(
        _Added_Columns,
        "All_Absent", 
        IF(
            [Total_Cands] = [Absent_Count],
            "Yes",
            "No"
        )
    )

RETURN
    COUNTROWS(
        FILTER(
            _Absent_Count,
            [All_Absent] = "No"
        )
    )


The specific part that I am having an issue with is here:

VAR _Added_Columns = 
    ADDCOLUMNS(
        _Summarized_Table,
        "Total_Cands", 
        CALCULATE(
            COUNTROWS(_Working_Table),
            FILTER(
                _Working_Table,
                _Working_Table[Concatenation] = EARLIER([Concatenation])
            )
        ),
        "Absent_Count", 
        CALCULATE(
            COUNTROWS(_Working_Table),
            FILTER(
                _Working_Table,
                _Working_Table[Concatenation] = EARLIER([Concatenation]) &&
                _Working_Table[Absent_Ind] = "A"
            )
        )
    )


Specifically in the CALCULATE when trying do do the following:

FILTER(
                _Working_Table,
                _Working_Table[Concatenation] = EARLIER([Concatenation])
            )

It appears as if I am not able to reference a column previously created with the ADDCOLUMNS function. 

How can I work around this?




1 ACCEPTED SOLUTION
RyanHare92
Helper I
Helper I

I still don't understand how DAX works in this context and how to referenced columns created with ADDCOLUMN, but after rubbing my two brain cells together, I managed to solve my issue by doing the following:

Expected_Entries = 
VAR _Summarized_Table = 
    SUMMARIZE(
        Current_Entries,
        [centre],
        [ass_code],
        [com_id]
    )

VAR _Final_Table = 
    ADDCOLUMNS(
        _Summarized_Table,
        "All_Absent",
        IF(
            CALCULATE(
                COUNTROWS(Current_Entries),
                Current_Entries[centre] = EARLIER([centre]),
                Current_Entries[ass_code] = EARLIER([ass_code]),
                Current_Entries[com_id] = EARLIER([com_id])
            )
            
            =

            CALCULATE(
                COUNTROWS(Current_Active_Marks),
                Current_Active_Marks[centre] = EARLIER([centre]),
                Current_Active_Marks[ass_code] = EARLIER([ass_code]),
                Current_Active_Marks[com_id] = EARLIER([com_id]),
                Current_Active_Marks[absent] = "A"
            ),
            "Yes",
            "No"
        )
    )

RETURN
    COUNTROWS(
        FILTER(
            _Final_Table,
            [All_Absent] = "No"
        )
    )

View solution in original post

1 REPLY 1
RyanHare92
Helper I
Helper I

I still don't understand how DAX works in this context and how to referenced columns created with ADDCOLUMN, but after rubbing my two brain cells together, I managed to solve my issue by doing the following:

Expected_Entries = 
VAR _Summarized_Table = 
    SUMMARIZE(
        Current_Entries,
        [centre],
        [ass_code],
        [com_id]
    )

VAR _Final_Table = 
    ADDCOLUMNS(
        _Summarized_Table,
        "All_Absent",
        IF(
            CALCULATE(
                COUNTROWS(Current_Entries),
                Current_Entries[centre] = EARLIER([centre]),
                Current_Entries[ass_code] = EARLIER([ass_code]),
                Current_Entries[com_id] = EARLIER([com_id])
            )
            
            =

            CALCULATE(
                COUNTROWS(Current_Active_Marks),
                Current_Active_Marks[centre] = EARLIER([centre]),
                Current_Active_Marks[ass_code] = EARLIER([ass_code]),
                Current_Active_Marks[com_id] = EARLIER([com_id]),
                Current_Active_Marks[absent] = "A"
            ),
            "Yes",
            "No"
        )
    )

RETURN
    COUNTROWS(
        FILTER(
            _Final_Table,
            [All_Absent] = "No"
        )
    )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.