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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
lt79_Pax
Helper II
Helper II

Data Lineage SelectOnlyC2 error

Dear Power BI Representative,

I am reviewing Chapter 14 of The Definitive Guide to DAX and in the 'Understanding data lineage' section I was running the following code in DAX Studio as directed.  However for some reason the SelectOnlyC2 variable DAX is not able to find C2 even though variable AddC2 is recognized if one sets the RETURN to AddC2 for testing.  The error I received was 'Query (18,34) Column 'C2' cannot be found or may not be used in this expression.'  Why is DAX unable to find C2 for the SelectOnlyC2 variable?  Your insight into this matter is much appreciated.

 

Thank you.

 

DEFINE

     MEASURE Sales[Sales Amount] =     

         SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )

EVALUATE

VAR NonBlueColors = 

    FILTER (

        ALL ( 'Product'[Color] ),

        'Product'[Color] <> "Blue"

    )

    

VAR AddC2 = 

    ADDCOLUMNS (

        NonBlueColors,

        "[C2]", 'Product'[Color]

    )

    

VAR SelectOnlyC2 = 

    SELECTCOLUMNS( AddC2, "C2",[C2])/*issue with this formula, DAX is not able to find C2.*/

    

VAR Result = ADDCOLUMNS ( SelectOnlyC2, "Sales Amount",[Sales Amount] )

RETURN Result

ORDER BY [C2]

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @lt79_Pax 

you probably need

VAR AddC2 =
    ADDCOLUMNS ( NonBlueColors"C2", 'Product'[Color] )

 

instead of

 

VAR AddC2 =
    ADDCOLUMNS ( NonBlueColors"[C2]", 'Product'[Color] )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

1 REPLY 1
AlB
Community Champion
Community Champion

Hi @lt79_Pax 

you probably need

VAR AddC2 =
    ADDCOLUMNS ( NonBlueColors"C2", 'Product'[Color] )

 

instead of

 

VAR AddC2 =
    ADDCOLUMNS ( NonBlueColors"[C2]", 'Product'[Color] )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.