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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Mary78
Helper II
Helper II

Filter problems


My _Measure is not delivering what I expected. I need a % for value on Status vs total
Supid measure give 100% when filterd using Status

Any Ideas?

Status and Values are columns in the same fact table
Value = Sum('FactTable[Values])

_Measure =
VAR D = [Value]
VAR AD =
    CALCULATE (
        D,
        ALL ( 'FactTable'[Status] )
    )
VAR RESULT =
    DIVIDE ( D, AD, BLANK () )
RETURN
    RESULT
1 ACCEPTED SOLUTION

Hi @Mary78 ,

Try this measure:

_Measure =
VAR D = [Value]  -- The current value based on filters
VAR AD =
    CALCULATE(
        [Value],
        ALLEXCEPT('FactTable', 'FactTable'[Other Columns...])  -- Preserve filters on other columns except Status
    )
VAR RESULT =
    DIVIDE(D, AD, BLANK())  -- Calculate the percentage
RETURN
    RESULT

 

If the above dont work, please consider to try this one with SUMX:

_Measure =
VAR D = [Value]
VAR AD =
    SUMX(
        ALL('FactTable'[Status]),
        CALCULATE(SUM('FactTable'[Values]))
    )
VAR RESULT =
    DIVIDE(D, AD, BLANK())
RETURN
    RESULT
I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

View solution in original post

11 REPLIES 11
Mary78
Helper II
Helper II

So this is a simplifyed version of my fact table:

date_id warehoue_idStatusDays
20240101 1Sent1

20240102

 

1Sent1
20240101 2packed1
20240102 2Sent1
20240101 1Sent1
20240102 1Sent1
20240101 2packed1
20240102 2Sent1
20240101 1Sent1
20240102 1Sent1


My goal is to have a measure that show days on a status vs days on all statuses in selected filter context.

So with this filtering
date = 20240101
Status = Sent 
Measure should give 60% ( 3 days on packed & 2 days on Sent = 5 days. 3/5= 0.6 60%)

Or with filter:
Warehouse = 2
Status = Packed
Measure should give 50% ( 2 days on packed & 2 days on Sent = 4 days. 2/4= 0.5 50%)

My problem is to get measure to ignore filter on status and return all days for date & warehouse filter context.




Ok I got it to work, looks like this

_TEST =
VAR D = [Days]
VAR AD =
CALCULATE (
[Days],
ALLEXCEPT ( 'factTable', 'factTable'[Warehouse_id], 'Date'[Date_id] )
)
VAR RESULT =
DIVIDE ( D, AD, BLANK () )
RETURN
RESULT

If I replace [Days] in VAR AD with D measures stops giving me all rows for Status.

Any ways it works, big thanks for all help and input 🙏

Hi @Mary78 ,

Happy it works.

 

 

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 
v-fenling-msft
Community Support
Community Support

Hi, @Mary78 

May I ask if you have gotten this issue resolved? If it is solved, please share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.


If it is not resolved, I hope you will provide the full .pbix file via OneDrive or SharePoint. Please be careful to remove all sensitive information and we will do our best to provide ideas for your issue.

 

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
dharmendars007
Solution Sage
Solution Sage

Hello @Mary78 , 

Your current measure divides the filtered Value by the total Value, ignoring the Status filter. However, the ALL function is removing only the Status filter, and this might not behave as expected when combined with other filters

 

Please try the below measure..

_Measure =
VAR D = [Value]
VAR AD = CALCULATE(
[Value],
REMOVEFILTERS('FactTable'[Status]))
VAR RESULT = DIVIDE(D, AD, 0)
RETURN RESULT

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

anmolmalviya05
Solution Sage
Solution Sage

Hi, please try below measure:
_Percentage =
VAR CurrentValue = SUM('FactTable'[Value]) -- Sum the current values
VAR TotalValue =
CALCULATE(
SUM('FactTable'[Value]),
REMOVEFILTERS('FactTable'[Status]) -- Remove filters on the 'Status' column
)
RETURN
DIVIDE(CurrentValue, TotalValue, BLANK())

Bibiano_Geraldo
Memorable Member
Memorable Member

Hi @Mary78 ,
Looking at your current approach, the issue likely arises because you're using the ALL function, which removes any filters on the Status column, causing the result to always be based on the total sum of values across all statuses, even when the table is filtered.

 

Please try this updated version of your measure:

 

_Measure =
VAR D = [Value]  -- The sum of 'FactTable[Values]' in the current context
VAR AD = 
    CALCULATE (
        [Value],  -- The total sum of values across the entire FactTable (not just filtered by Status)
        REMOVEFILTERS('FactTable'[Status])  -- This removes only the filter on the 'Status' column
    )
VAR RESULT =
    DIVIDE(D, AD, BLANK())  -- Dividing the current value by the total value to get the percentage
RETURN
    RESULT

 

 

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

Thanks all you guys for the replys,  unfortunatly non of them have solve my issue.

Then thing is that this format for a % measure work fine when column i don´t want filterd are in a dim tabel and not in the fact were the value is.

So maby issue is that value and column I want to removefilter on are in the same table? 

Hi @Mary78 ,

Try this measure:

_Measure =
VAR D = [Value]  -- The current value based on filters
VAR AD =
    CALCULATE(
        [Value],
        ALLEXCEPT('FactTable', 'FactTable'[Other Columns...])  -- Preserve filters on other columns except Status
    )
VAR RESULT =
    DIVIDE(D, AD, BLANK())  -- Calculate the percentage
RETURN
    RESULT

 

If the above dont work, please consider to try this one with SUMX:

_Measure =
VAR D = [Value]
VAR AD =
    SUMX(
        ALL('FactTable'[Status]),
        CALCULATE(SUM('FactTable'[Values]))
    )
VAR RESULT =
    DIVIDE(D, AD, BLANK())
RETURN
    RESULT
I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 
ribisht17
Super User
Super User

hi @Mary78 

 

Please try ALLSELECTED there

 

ribisht17_0-1732883866344.png

 

 

Regards,

Ritesh

✔️ Please mark the answer if helpful so that it can help others as well😊

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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