Forum Discussion

Dave1mo1's avatar
Dave1mo1
Helper III
1 year ago
Solved

Count Unique Dimension Based on Fact Table

Hi,

 

I'm trying to count the unique number of dealerships represented in the data for the current fiscal year of my fact table.

 

Relevant relationships:

 

FY Date Table [Date] -----> Activity Log Fact Table [Activity Date]

Dealership Lookup Table [Dealer ID] -----> Dealer Users Lookup [Dealer ID]

Dealer Users Lookup [User ID] -----> Activity Log Fact Table [User ID]

 

I've tried to utilize distinctcount, but any time I try to put a fiscal year filter on the visual, I get a "blank" value (see below). I'm not great with DAX, and this is frustrating!

 

Unique Dealership Logins = calculate(
    DISTINCTCOUNT(
        'Dealership Lookup Table' [Dealer ID]),
    filter(
        'Activity Log Fact Table', 'Activity Log Fact Table' [User ID]),
    USERELATIONSHIP(
        'FY Date Table'[Date], 'Activity Log Fact Table' [Activity Date])
    )
 
 
Thanks for any help you can offer.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Dave1mo1 ,

    Please update the formula of your measure [Unique Dealership Logins] as below and check if it can return the expected result...

     

    Unique Dealership Logins =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Activity Log Fact Table'[User ID] ),
            FILTER (
                'Activity Log Fact Table',
                'Activity Log Fact Table'[Activity Date]
                    IN ALLSELECTED ( 'FY Date Table'[Date] )
            )
        )
    RETURN
        CALCULATE (
            DISTINCTCOUNT('Dealership Lookup Table'[Dealer ID]),
            FILTER ( 'Dealer Users Lookup', 'Dealer Users Lookup'[User ID] IN _tab )
        )

     

    If the above one can't help you figure out, please provide some raw data in above 4 tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

3 Replies

  • hi Dave1mo1 ,

     

    Try like:

    Measure =

    COUNTROWS(

        SUMMARIZE(

            'Activity Log Fact Table',

            'Dealership Lookup Table' [Dealer ID]

         )

    )

  • KNP's avatar
    KNP
    Super User

    I'm not 100% sure without seeing your full model but you could try something like this...

     

    dealer count = 
        COUNTROWS(
            SUMMARIZECOLUMNS(
                'Dealership Lookup Table' [Dealer ID], 
                "value", [A Measure From Your Fact Table]
            )
        )
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Dave1mo1 ,

    Please update the formula of your measure [Unique Dealership Logins] as below and check if it can return the expected result...

     

    Unique Dealership Logins =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Activity Log Fact Table'[User ID] ),
            FILTER (
                'Activity Log Fact Table',
                'Activity Log Fact Table'[Activity Date]
                    IN ALLSELECTED ( 'FY Date Table'[Date] )
            )
        )
    RETURN
        CALCULATE (
            DISTINCTCOUNT('Dealership Lookup Table'[Dealer ID]),
            FILTER ( 'Dealer Users Lookup', 'Dealer Users Lookup'[User ID] IN _tab )
        )

     

    If the above one can't help you figure out, please provide some raw data in above 4 tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards