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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
gssffh
Regular Visitor

REMOVEFILTERS including more records than intended

I'm sure this is a basic question that I just haven't found the right Google search terms for. I have some dental data where I am trying to include patients treated on a specific day, but summarize all procedures regardless of date just for those patients. If I create a measure using CALCULATE that includes REMOVEFILTERS for the date column, it is calculating the correct number of procedures for each patient (e.g. placing the measure in a table where it is summarizing for each patient), but when placing this measure on a card it is including all procedures for all patients. It makes sense to me why this would happen, but I can't think of a solution. Here is is the formula:

 

Cavities Needing Filled = CALCULATE(COUNT('Data'[PROC_LOGIDDB]), Data[ADACODE] >= "D2140" && Data[ADACODE] <= "D3999", Data[CHART_STATUS] >= 105 && Data[CHART_STATUS] <= 107, REMOVEFILTERS(Data[PLDATE]))
5 REPLIES 5
v-xicai
Community Support
Community Support

Hi  @gssffh  ,

 

Do the suggestions from engineers make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

Sorry @v-xicai, but it is still not working. It only gave returned a value of 1 for a single patient. I also tried

Cavities Needing Filled Test =
CALCULATE(
COUNT('Data'[PROC_LOGIDDB]), Data[ADACODE] >= "D2140" && Data[ADACODE] <= "D3999" || Data[ADACODE] = "RCTREF", Data[CHART_STATUS] >= 105 && Data[CHART_STATUS] <= 107,
ALLSELECTED(Data[CHART]), REMOVEFILTERS(Data[PLDATE])
)
 
However, it gives me the same result as my original DAX statement.
v-xicai
Community Support
Community Support

Hi @gssffh ,

 

From the article, we know that REMOVEFILTERS function is identical to the ALL function, which will take effect of all selections for Data[PLDATE].

 

You may change the formula like DAX below.

 

 

Cavities Needing Filled =
IF (
    HASONEFILTER ( Data[PLDATE] ),
    CALCULATE (
        COUNT ( 'Data'[PROC_LOGIDDB] ),
        FILTER (
            'Data',
            Data[ADACODE] >= "D2140"
                && Data[ADACODE] <= "D3999"
                && Data[CHART_STATUS] >= 105
                && Data[CHART_STATUS] <= 107
        )
    )
)

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mpicca13
Resolver IV
Resolver IV

You said your looking by specific date, are you using a date filter?

If so maybe replacing REMOVEFILTERS() with ALLSELECTED().

 

 

Yes, I am using a date slicer on PLDATE and allowing only one date at a time to be selected. I tried replacing REMOVEFILTERS with ALLSELECTED and now it only returns a quantity of 1 for a single patient.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.