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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
garythomannCoGC
Impactful Individual
Impactful Individual

sql where in dax equivalent

Wondering what change is needed to the query below.  Trying to add a 'where' clause to the working query.

The first commented bit of the filter is what I want.  The other lines are failing tests.

 

Simple dataset table

garythomannCoGC_0-1658988453112.png

 

The dax query

 

EVALUATE 
    FILTER ( 
        SELECTCOLUMNS (
             'CPP Traffic Light Short Status',
             "Short Status Name",   'CPP Traffic Light Short Status'[Short Status Name],
             "Unichar Glyph",       UNICHAR ('CPP Traffic Light Short Status'[Unicode Decimal]),
             "Colour Hex",          'CPP Traffic Light Short Status'[Colour Hex], 
             "Font Size",           'CPP Traffic Light Short Status'[Font Size], 
             "Font Size Offset",    'CPP Traffic Light Short Status'[Font Size Offset] 
        ),
--        'CPP Traffic Light Short Status'[Status Code] IN {0, 1, 2, 3, 10}
--        MAX('CPP Traffic Light Short Status'[Status Code]) = 0
          MAX('CPP Traffic Light Short Status'[Short Status Name]) = "Not Reported"
    )
ORDER BY [Short Status Name]

 

 

1 ACCEPTED SOLUTION
garythomannCoGC
Impactful Individual
Impactful Individual

Replace filter with calculatetable command :}

 

EVALUATE 
--    FILTER ( 
    CALCULATETABLE ( 
        SELECTCOLUMNS (
             'CPP Traffic Light Short Status',
             "Short Status Name",   'CPP Traffic Light Short Status'[Short Status Name],
             "Unichar Glyph",       UNICHAR ('CPP Traffic Light Short Status'[Unicode Decimal]),
             "Colour Hex",          'CPP Traffic Light Short Status'[Colour Hex], 
             "Font Size",           'CPP Traffic Light Short Status'[Font Size], 
             "Font Size Offset",    'CPP Traffic Light Short Status'[Font Size Offset] 
        ),
        'CPP Traffic Light Short Status'[Status Code] IN {0, 1, 2, 3, 10}
--        'CPP Traffic Light Short Status'[Status Code] = 0
--          'CPP Traffic Light Short Status'[Short Status Name] = "Not Reported"
    )
ORDER BY [Short Status Name]

View solution in original post

2 REPLIES 2
garythomannCoGC
Impactful Individual
Impactful Individual

Ok so how to make the filter command work for my scenario?  

garythomannCoGC
Impactful Individual
Impactful Individual

Replace filter with calculatetable command :}

 

EVALUATE 
--    FILTER ( 
    CALCULATETABLE ( 
        SELECTCOLUMNS (
             'CPP Traffic Light Short Status',
             "Short Status Name",   'CPP Traffic Light Short Status'[Short Status Name],
             "Unichar Glyph",       UNICHAR ('CPP Traffic Light Short Status'[Unicode Decimal]),
             "Colour Hex",          'CPP Traffic Light Short Status'[Colour Hex], 
             "Font Size",           'CPP Traffic Light Short Status'[Font Size], 
             "Font Size Offset",    'CPP Traffic Light Short Status'[Font Size Offset] 
        ),
        'CPP Traffic Light Short Status'[Status Code] IN {0, 1, 2, 3, 10}
--        'CPP Traffic Light Short Status'[Status Code] = 0
--          'CPP Traffic Light Short Status'[Short Status Name] = "Not Reported"
    )
ORDER BY [Short Status Name]

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.