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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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