Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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 ma...
  • Jihwan_Kim's avatar
    2 years ago

    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.

     

     

     

     

     

    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] )
        )