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
NickCC
Regular Visitor

Help: How to simple use a filter in DAX

Hello, 

 

I am having an issue with a simple filter for a new measure. 

Following settup: 

In the measure Attribute Name different text values like Brand, Gendre etc. are included

Hereby the Attribute Value gives out the corresponding value like men or woman. 

 

I tried to calculate a new measure using the calculate and all formula to just show the different brands. 

Brand = calculate(All(ArticleAttributes[Attribute Value]), ArticleAttributes[Attribute Name]="Marke")
 
Sadly it doesn*t work. 
Does anyone have an idea? With the sum formula it doesn't work as well.
 
Kind regards 
Nick 
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @NickCC ,

I created some data:

vyangliumsft_0-1715067501195.png

Do you want to use Dax to achieve the following effects:

vyangliumsft_1-1715067501195.png

Here are the steps you can follow:

If [Attribute Value] is not a duplicate value in your data, you can try the following dax:

no - repetitive =
MAXX(
    FILTER(ALL('Table'),[AttributeName]="Marke"&&'Table'[Attribute Value]=MAX('Table'[Attribute Value])),[Attribute Value])

vyangliumsft_2-1715067518229.png

If your [Attribute Value] is a duplicate value, you can create an index to mark it.

Add Column – Index Column – From 1.

vyangliumsft_3-1715067539117.png

repetitive =
MAXX(
    FILTER(ALL('Table'),[AttributeName]="Marke"&&'Table'[Index]=MAX('Table'[Index])),[Attribute Value])

vyangliumsft_4-1715067539118.png

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @NickCC ,

I created some data:

vyangliumsft_0-1715067501195.png

Do you want to use Dax to achieve the following effects:

vyangliumsft_1-1715067501195.png

Here are the steps you can follow:

If [Attribute Value] is not a duplicate value in your data, you can try the following dax:

no - repetitive =
MAXX(
    FILTER(ALL('Table'),[AttributeName]="Marke"&&'Table'[Attribute Value]=MAX('Table'[Attribute Value])),[Attribute Value])

vyangliumsft_2-1715067518229.png

If your [Attribute Value] is a duplicate value, you can create an index to mark it.

Add Column – Index Column – From 1.

vyangliumsft_3-1715067539117.png

repetitive =
MAXX(
    FILTER(ALL('Table'),[AttributeName]="Marke"&&'Table'[Index]=MAX('Table'[Index])),[Attribute Value])

vyangliumsft_4-1715067539118.png

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

Ajithkumar_03
Frequent Visitor

Hi @NickCC 

Can I get sample data?

 

johnbasha33
Solution Sage
Solution Sage

@NickCC 

It looks like you're trying to create a measure to filter and display only the values corresponding to the "Brand" attribute in your data model. However, the DAX expression you provided seems to be missing a key component to achieve this.

Here's a revised version of your measure that should work:

```dax
Brand =
CALCULATE(
VALUES(ArticleAttributes[Attribute Value]),
FILTER(
ArticleAttributes,
ArticleAttributes[Attribute Name] = "Marke"
)
)
```

This measure uses the CALCULATE function along with VALUES and FILTER to filter the values in the "ArticleAttributes" table where the "Attribute Name" is equal to "Marke". It then returns the distinct values of the "Attribute Value" column for the filtered rows.

Make sure to replace "ArticleAttributes" with the actual name of your table containing the attribute data.

You can use this "Brand" measure in your Power BI visuals to display the distinct brands based on the "Marke" attribute. If you encounter any issues or have further questions, feel free to ask!

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

Sadly it doesn't work. 

If I let the Measure "Attribute Value" be displayed in a table and use the visual filter (inserting Attribue Name -> "Marke") it works. 

What could be the problem? 

 

@NickCC 

there could be a few potential reasons for this discrepancy:

  1. Context Transition: Calculated measures in Power BI operate within a context, which may differ from the context applied by visual filters. If the measure isn't correctly handling context transition, it may not produce the expected results.

  2. Relationships: Ensure that there is a proper relationship established between the tables involved in your calculation. If the tables are not related correctly, the measure may not filter the data as expected.

  3. Filter Propagation: Verify that the filter is being propagated correctly through the data model. If the filter is not applied to all relevant tables, the measure may not return the expected results.

  4. Data Model Structure: Review the structure of your data model to ensure that it aligns with your intended analysis. Check for any inconsistencies or unexpected behaviors in the data model that may affect the measure's calculation.

  5. Debugging: Use DAX Studio or Power BI's built-in tools to debug and troubleshoot the measure. You can evaluate the measure in different contexts to identify any issues with its calculation logic.

  6. Syntax Errors: Double-check the syntax of your DAX measure to ensure that it is correctly written and references the appropriate columns and tables.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.