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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ellac
Helper III
Helper III

Data modeling - create a relationship and filter a dimension

Hi,

I have an issue that I can't wrap my head around regarding the relationship between a dimension table and a fact table.

Background:

  • We have a data model with a star schema structure. Let's make it very simple for this example - we have a Product table (dimension) and a Sales table (fact) linked by a relationship between the column called "ArticleID".
  • The Product table has a unique product per row, and the Sales table can have several rows with the same product. Nothing weird so far.
  • We then have a Markdown table which consists of Markdown history for every product i.e. one product can exist on multiple rows. For example, product A has had three different markdowns, resulting in three rows in the table.
  • Not all products in the Product Table exist in the Markdown table.

The problem:

Let's say we have a Markdown called "Summer Markdown" consisting of 200 products, i.e. 200 products got a reduced price during the "Summer Markdown". I want to be able to see what the Sales are for these 200 products. Therefore, I want to filter the Product table from the Markdown table '(when I select "Summer Markdown"), see the picture below. And this doesn't work, except if we break the star model structure and thus significantly degrade the performance of the model.

ellac_0-1723115535552.png

 

So far, I've created a hidden many-to-many relationship (had to make a many-to-many relation in Tabular Editor) between the Markdown table and the Product table (Markdown filtering Product), then enabled it in specific measures. But this makes both the report and model REALLY slow.

 

My plan B is to remake my Markdown table to be a dimension and then in some way connect it directly to the Sales table, so I don't have to go "over" the Product table.

 

Does anyone have any ideas on how to solve this? And not decreasing the model performance. Let me know if I was unclear 🙂

 

/Ella

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1723122068537.png

 

 

Jihwan_Kim_0-1723122042039.png

 

 

Sales: =
VAR _ProductByMarkdownTypeByDate =
    SUMMARIZE (
        GENERATE (
            markdown,
            FILTER (
                'calendar',
                'calendar'[Date] >= markdown[markdown_startdate]
                    && 'calendar'[Date] <= markdown[markdown_enddate]
            )
        ),
        markdown[article_id],
        'calendar'[Date]
    )
RETURN
    IF (
        ISFILTERED ( markdown_type[markdown_type] ),
        CALCULATE (
            SUM ( sales[sales_amount] ),
            TREATAS (
                _ProductByMarkdownTypeByDate,
                'product'[article_id],
                'calendar'[Date]
            )
        ),
        SUM ( sales[sales_amount] )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1723122068537.png

 

 

Jihwan_Kim_0-1723122042039.png

 

 

Sales: =
VAR _ProductByMarkdownTypeByDate =
    SUMMARIZE (
        GENERATE (
            markdown,
            FILTER (
                'calendar',
                'calendar'[Date] >= markdown[markdown_startdate]
                    && 'calendar'[Date] <= markdown[markdown_enddate]
            )
        ),
        markdown[article_id],
        'calendar'[Date]
    )
RETURN
    IF (
        ISFILTERED ( markdown_type[markdown_type] ),
        CALCULATE (
            SUM ( sales[sales_amount] ),
            TREATAS (
                _ProductByMarkdownTypeByDate,
                'product'[article_id],
                'calendar'[Date]
            )
        ),
        SUM ( sales[sales_amount] )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Wow @Jihwan_Kim , this is really the solution that I need! Thanks A LOT!

DataInsights
Super User
Super User

@ellac,

 

You should be able to create a one-to-many relationship between Product and Markdown (join on ArticleID). Then create a measure like the one below. The CROSSFILTER function allows bidirectional filtering within the scope of the measure.

 

Amount =
CALCULATE (
    SUM ( Sales[Amount] ),
    CROSSFILTER ( Markdown[ArticleID], Product[ArticleID], BOTH )
)

 





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

Proud to be a Super User!




mickey64
Super User
Super User

For your reference.

mickey64_0-1723120624961.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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