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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Michal_cwiok
Resolver II
Resolver II

DAX measure that ignores part of the filter

Hi,

One calculated measure is giving me a hard time and I wanted to consult with the community. As my client requested, the dashboard should enable users to see their results only (a rather simple RLS solution), but also aggregated results of other users but only for products in the same class as the first user. A good example would be with retail suppliers and sales (products are in a hierarchy: class -> subclass -> SKU):

 

Sales Details  Market Details
 
SKUSales Products hierarchySales
Supplier1 SKU1125 Class 1840
Supplier1 SKU2124      Subclass1.1587
Supplier1 SKU3106      Subclass1.2253
Supplier1 SKU4110 Class21061
Supplier1 SKU5127      Subclass2.1604
Supplier1 SKU6102      Subclass2.2457

 

Is it possible to create such a DAX query that takes into account the classes and subclasses of the Supplier1 and shows sales results for all of the supplier for those classes and subclasses?

 

I was trying to use query like below, but without success:

 

Sales_subclass := CALCULATE(Sales;ALL(Supplier[SupplierName]);FILTERS(Products[Subclass]))

Which (as I see it) takes the existing filters from the subclass column and applies them to the data ignoring the filter for supplier. Unfortunatelly this does not work and still applies supplier as a filter.

 

Would appreciate any help, thank you.

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee


@Michal_cwiok wrote:

Hi,

One calculated measure is giving me a hard time and I wanted to consult with the community. As my client requested, the dashboard should enable users to see their results only (a rather simple RLS solution), but also aggregated results of other users but only for products in the same class as the first user. A good example would be with retail suppliers and sales (products are in a hierarchy: class -> subclass -> SKU):

 

Sales Details     Market Details
 
SKU Sales   Products hierarchy Sales
Supplier1 SKU1 125   Class 1 840
Supplier1 SKU2 124        Subclass1.1 587
Supplier1 SKU3 106        Subclass1.2 253
Supplier1 SKU4 110   Class2 1061
Supplier1 SKU5 127        Subclass2.1 604
Supplier1 SKU6 102        Subclass2.2 457

 

Is it possible to create such a DAX query that takes into account the classes and subclasses of the Supplier1 and shows sales results for all of the supplier for those classes and subclasses?

 

I was trying to use query like below, but without success:

 

Sales_subclass := CALCULATE(Sales;ALL(Supplier[SupplierName]);FILTERS(Products[Subclass]))

Which (as I see it) takes the existing filters from the subclass column and applies them to the data ignoring the filter for supplier. Unfortunatelly this does not work and still applies supplier as a filter.

 

Would appreciate any help, thank you.


@Michal_cwiok

I don't think a measure could do that, RLS is applied to dataset(the data you don't have access is missing in tables). You may implment that by re-modeling your data, eg, create an aggregated calculated table 

aggreagated Table =
SUMMARIZE (
    'Source table',
    'Source table'[subclass],
    "sales in the subclass", SUM ( 'Source table'[sales] )
)

Capture.PNG

 

 

Before RLS applied.

Capture.PNG

 

When RLS is applied for user1.

Capture.PNG

 

See the attached demo.

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee


@Michal_cwiok wrote:

Hi,

One calculated measure is giving me a hard time and I wanted to consult with the community. As my client requested, the dashboard should enable users to see their results only (a rather simple RLS solution), but also aggregated results of other users but only for products in the same class as the first user. A good example would be with retail suppliers and sales (products are in a hierarchy: class -> subclass -> SKU):

 

Sales Details     Market Details
 
SKU Sales   Products hierarchy Sales
Supplier1 SKU1 125   Class 1 840
Supplier1 SKU2 124        Subclass1.1 587
Supplier1 SKU3 106        Subclass1.2 253
Supplier1 SKU4 110   Class2 1061
Supplier1 SKU5 127        Subclass2.1 604
Supplier1 SKU6 102        Subclass2.2 457

 

Is it possible to create such a DAX query that takes into account the classes and subclasses of the Supplier1 and shows sales results for all of the supplier for those classes and subclasses?

 

I was trying to use query like below, but without success:

 

Sales_subclass := CALCULATE(Sales;ALL(Supplier[SupplierName]);FILTERS(Products[Subclass]))

Which (as I see it) takes the existing filters from the subclass column and applies them to the data ignoring the filter for supplier. Unfortunatelly this does not work and still applies supplier as a filter.

 

Would appreciate any help, thank you.


@Michal_cwiok

I don't think a measure could do that, RLS is applied to dataset(the data you don't have access is missing in tables). You may implment that by re-modeling your data, eg, create an aggregated calculated table 

aggreagated Table =
SUMMARIZE (
    'Source table',
    'Source table'[subclass],
    "sales in the subclass", SUM ( 'Source table'[sales] )
)

Capture.PNG

 

 

Before RLS applied.

Capture.PNG

 

When RLS is applied for user1.

Capture.PNG

 

See the attached demo.

 

Michal_cwiok
Resolver II
Resolver II

I have also tried this approach:

 

CALCULATE(CALCULATE(Sales[Sales];ALL(Supplier[SupplierName]));CALCULATETABLE('Product';FILTERS('Products'[SubClass]))) 

but also without success.

 

Thank you

 

Helpful resources

Announcements
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.