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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter Criteria on Caluculation

% Of Sales By SubCategory =

DIVIDE([_TotalSales],CALCULATE([_TotalSales],ALL(DimProductSubcategory[ProductSubcategoryName]) ),0)*100

 

here i would like to Filter only records whose % is more than 10%

can some one rewrite the expression for me

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You can modify your formula to return tag, then drag it to visual level filter to filter unmatched records:

% Of Sales By SubCategory =
VAR SalesBySubCat =
    CALCULATE (
        [_TotalSales],
        ALL ( DimProductSubcategory[ProductSubcategoryName] )
    )
VAR PercentOfSale =
    DIVIDE ( [_TotalSales], SalesBySubCat, 0 ) * 100
RETURN
    IF ( PercentOfSale > 10, 1, 0 )

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

% Of Sales By SubCategory = 
VAR SalesBySubCat=CALCULATE([_TotalSales],ALL(DimProductSubcategory[ProductSubcategoryName]))
VAR PercentOfSale =DIVIDE([_TotalSales],SalesBySubCat,0)*100
Return 
PercentOfSale>10

//here from below screen shot i want only true records to be displayed.

Capture11.PNG

 

Anonymous
Not applicable

Any  solution for this please.

Stachu
Community Champion
Community Champion

if you want to use the DAX filter you will also need to put it in the [SalesAmount] as well - otherwise it will give you blank for the % measure, and amounts for the [SalesAmount]
@Anonymous solution prevents that
Otherwise I would try with something like:

VAR SalesBySubCat=CALCULATE([_TotalSales],ALL(DimProductSubcategory[ProductSubcategoryName]))
VAR PercentOfSale =DIVIDE([_TotalSales],SalesBySubCat,0)*100
VAR SubCategoryFilter = FILTER(ADDCOLUMNS(SUMMARIZE('DimProductSubcategory',DimProductSubcategory[ProductSubcategoryName]),"Val",PercentOfSale),[Val]>10)
RETURN 
CALCULATE(DIVIDE([_TotalSales],SalesBySubCat,0)*100,SubCategoryFilter)

idea is to 'summarize' current subcategory by PercentOfSale and filter out those that do not meet the criteria and then use that as a CALCULATE parameter
Also you cannot use the PercentOfSale cause it will always return value from before you have filtered



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Have you tried placeing the [% Of Sales By SubCategory] into your report filters and setting it to only show "True"?

Anonymous
Not applicable

Thanks Ross for reply,actually i dont want to fiter it by slicer or Default filters,but to filter using DAX expression on caluculated result set.

Anonymous
Not applicable

% Of Sales By SubCategory = 
VAR SalesBySubCat=CALCULATE([_TotalSales],ALL(DimProductSubcategory[ProductSubcategoryName]))
VAR PercentOfSale =DIVIDE([_TotalSales],SalesBySubCat,0)*100
Return 
PercentOfSale>10

here instead of retruning True or False i want only True records to be fetched,False should be excluded in result.11.png

Hi @Anonymous,

 

You can modify your formula to return tag, then drag it to visual level filter to filter unmatched records:

% Of Sales By SubCategory =
VAR SalesBySubCat =
    CALCULATE (
        [_TotalSales],
        ALL ( DimProductSubcategory[ProductSubcategoryName] )
    )
VAR PercentOfSale =
    DIVIDE ( [_TotalSales], SalesBySubCat, 0 ) * 100
RETURN
    IF ( PercentOfSale > 10, 1, 0 )

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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