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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
msmays5
Helper II
Helper II

Cross Filter Multiple Fact Tables

Hi everyone,

 

I have the following tables, plus a date table (fact tables in green, dimension tables in yellow)

image.png

 

There are the following relationships:

1. 'Articles'[ArticleID] --> 'Article Views'[ArticleId]

2. 'Articles'[ArticleID] --> 'Article Tags'[ArticleId]

3. 'Countries'[Country] --> 'Article Tags'[Country]

4. 'DateTable'[Date] --> 'Article Views'[Date]

 

GOAL: Display the % of Articles Assigned to a Country with Incremental Views In Month. In other words: Count the articles visible to each country if that article had an incrmental view in the selected month and divide by all articles visible to the country

 

I have the following measures already created, but I'm not sure how to calculate the above: 

 

 

# of Articles Visible to Country:=
CALCULATE (
    DISTINCTCOUNT ( 'Article Tags'[ArticleId] ),
    CROSSFILTER ( 'Articles'[ArticleId], 'Articles Tags'[ArticleId], BOTH )
)
---------------------------------------------------------------------------------
# of Incremental Article Views in Month:= 
VAR _NumberInLatestMonth = [# of Cumulative Article Views]
VAR _NumberInPriorMonth = 
    CALCULATE (
            [# of Cumulative Article Views],
            PREVIOUSMONTH ( DateTable[Date] )
        )
RETURN
    _NumberInLatestMonth - _NumberInPriorMonth    

 

 

 

Any help would be greatly appreicated! If anything I listed isn't clear, please let me know. Thanks so much

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@msmays5 , although your senario isn't that logical (the Article Views table doesn't have a country identifier), I came up with a solution in line with your description; you might want to refer to the attached file for details.

Measure = 
VAR __articles = CALCULATETABLE ( DISTINCT ( dArticle[ArticleID] ), CALCULATETABLE ( fTag ) )
RETURN
    DIVIDE (
        SUMX (
            __articles,
            VAR __prev =
                CALCULATE ( [Views], PREVIOUSMONTH ( dDate[Date] ) )
            RETURN
                 ( [Views] > __prev ) + 0
        ),
        [# of Articles Visible to Country]
    )

Screenshot 2020-11-07 170817.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
Nickiman
Regular Visitor

I have 2 fact tables that I would like to consolidate in a matrix viz that match/ align the (dates/transaactions) rows from those 2 fact tables , any suggestion pls? any help is much appreciated thank you so much!

Nickiman_0-1630320585742.png

 

 

 

msmays5
Helper II
Helper II

@ctaulbee An incremental view is a new view in a given month. So articles 1, 2, and 3 each had incrmental views in February, while articles 4 and 5 didn't. Yes, you are correct that summing cumulative views would be double counting.

 

You are also correct that the Article Views table doesn't have a country identifier - that's because we don't actually have that data available in the data source. So what I want to understand is that, among articles tagged to a particular country, what % had incremental views in a given month. To be specific, Canada has access to articles 1 and 2, each of which had incremental views in Februrary, so the value would be 100% (2/2). Mexico has access to two articles 1 and 5. Because articles 1 had incremental views in February but article 2 didn't, the value for Mexico would be 50%.

 

I agree it's not the mose meaningful metric, but it's what I've been asked to provide.

CNENFRNL
Community Champion
Community Champion

@msmays5 , although your senario isn't that logical (the Article Views table doesn't have a country identifier), I came up with a solution in line with your description; you might want to refer to the attached file for details.

Measure = 
VAR __articles = CALCULATETABLE ( DISTINCT ( dArticle[ArticleID] ), CALCULATETABLE ( fTag ) )
RETURN
    DIVIDE (
        SUMX (
            __articles,
            VAR __prev =
                CALCULATE ( [Views], PREVIOUSMONTH ( dDate[Date] ) )
            RETURN
                 ( [Views] > __prev ) + 0
        ),
        [# of Articles Visible to Country]
    )

Screenshot 2020-11-07 170817.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL Sorry for the delayed response; when I first implemented the measure, it wasn't working for me, but I realized that my model had a relationship that caused it to not be in star schema. Once I fixed this, your answer worked perfectly! Thank you so much for your help!

ctaulbee
New Member

It's a little hard to follow what you're hoping to accomplish. Not sure what you mean by an incremental view.

 

If you have cumulative counts by month in your first fact table, does that mean if you simply sum 2 months you'd be double counting the first month?

 

Also, you have no country identifier in your first fact table, so if you take a sum of the article views and divide it by total number of countries who had access to that article, what would that tell you? 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.