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
cathoms
Responsive Resident
Responsive Resident

Problems using SUMX, FILTER, and VALUE together

Taking a different approach to a problem I posted about yesterday.

 

I'm trying to create a measure that I can use to flag types of coding changes based on the measure results. The codes are stored as strings. Unfortunately, a few codes within my existing columns are alphanumeric combinations, not just numbers.

 

I'm trying to filter those values out then subtract one column from the other but I get an error suggesting those items were not filtered. Can anyone help? DAX measure below followed by screenshot of the error.

 

CodeChangeDiff = 
SUMX (
        FILTER (
            UclFact,
            NOT ( [OriginalProcedureFinal] = "NCG11"
                || [OriginalProcedureFinal] = "G2212"
                || [OriginalProcedureFinal] = "N9211" )
        ),
        VALUE ( UclFact[OriginalProcedureFinal] )
    )
- 
SUMX (
            FILTER (
                UclFact,
                NOT ( [OriginalProcedureFinal] = "NCG11"
                    || [OriginalProcedureFinal] = "G2212"
                    || [OriginalProcedureFinal] = "N9211" )
            ),
            VALUE ( UclFact[CurrentProcedureFinal] )
        )

 

cathoms_0-1650483771729.png

 

1 ACCEPTED SOLUTION
cathoms
Responsive Resident
Responsive Resident

I ended up creating a calculated column that returns blank values for rows where there were letters in the codes. I end up with several "undefined" cases but still far better than doing everything manually, which is the current state.

View solution in original post

5 REPLIES 5
davehus
Memorable Member
Memorable Member

Hi  @cathoms , have your tried using a calculated column with an if statement to set the alphanumerics as 0. I tried it there on a DQ I have, it's not alphamumeric but it worked. In the above you are using an OR clause with the || should this not be AND() or &&?

cathoms
Responsive Resident
Responsive Resident

I ended up creating a calculated column that returns blank values for rows where there were letters in the codes. I end up with several "undefined" cases but still far better than doing everything manually, which is the current state.

davehus
Memorable Member
Memorable Member

Hi @cathoms ,

 

Are you able to maybe do something at powerquery level to replace the alpha values with null. Your columns are still being defined as text with them containing the alpahnumeric, so the filter context doesn't resovle this. You could do something with an if statment column to replace the values and work your cacluation or a complex measure. 

 

Sometimes the easiest is best. 🙂 

cathoms
Responsive Resident
Responsive Resident

Unfortunately, not in this case. We have database report writers who build most of our Power BI datasets and I am building a .pbix report based on such a dataset. To make any changes to the data model I need to use Direct Query mode, which doesn't give me the option to transform the data in Power Query.

I'm learning today that there are a number of very frustrating limits on what DAX functions can be used in creating new columns in DirectQuery mode.

Hi @cathoms , Don't get me started on it. I've recently started developing reports in Dynamics and using DQ more frequently (have always imported data), so having to find different solutions and doing a lot more work upstream in the model, but these are the challenges I suppose. Let me have a think on it. I might come up with something for you. 

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.