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
Anonymous
Not applicable

DAX FILTER SYNTAX

Hello all , 

I need your help please

I  have two tables - orders and products category 

products culumns  category , sub_category ,  product_id  ( product_id  can be in many sub_categories)

orders culumns - cust_id , order_date ,product_id , category , sub_category 

 

how can I create a measure that showes only orders of products that have more than one sub_category ?

6 REPLIES 6
Anonymous
Not applicable

Why do both of your tables have fields "category" and "sub_category"? Is it not enough to store these is the Products dimension?

Best
D
Anonymous
Not applicable

no ...i need it to create a relation between the tables so on could filter the other

Anonymous
Not applicable

You can't create a relationship between 2 tables on many columns. Secondly, slicing Orders by category and sub_category should be carried out via Products where these columns (should) reside. Please note that slicing should NEVER be done directly on a fact table, only via dimensions. If you don't follow the rules, you'll be sorry rather sooner than later. Even better, you'll be creating complex and potentially slow DAX which at times will return wrong results without you even realizing this.

 

Consider yourself warned (for your own good).

 

Best

D

Anonymous
Not applicable

By the way... If your products belong to many subcategories, then you should have a hidden bridge table from ProductId to SubcategoryId which will join to Products and Subcategories on both sides and slicing should be then performed via Products and/or Subcategories.

Best
D
Anonymous
Not applicable

The filter is by the category (pk)

 

anyone knowes how to create this DAX ?

Greg_Deckler
Super User
Super User

Something along the lines of:

 

Measure =
  VAR __Products = 
    FILTER(
      GROUPBY(
        'products culumns',
        [product_id],
        "Count",COUNTX(CURRENTGROUP(),[sub_category])
      ),
      [Count]>1
    )
RETURN
  <some calculation where FILTER('orders culumns',[product_id] IN __Products) >
  


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.