Forum Discussion

Andreas_Wacker's avatar
Andreas_Wacker
Frequent Visitor
5 years ago
Solved

Creating bar chart total visits with dynamic distinct count

Hello all,


a task that seems simple at first sight gets more complicated with every hour I spend trying, reading and thinking about it. If there is already a post about this, I didn't notice it because I guess I don't have the right words to describe it.


I have a chart with Customer_ID and Date(YYYY.MM.DD):

 

Customer_IDDate (YYYY.MM.DD)
12021.01.01
22021.01.02
32021.01.03
12021.01.04
12021.01.05
22021.01.06
42021.01.07
12021.01.08

 

At the end I want to create a chart from these data by
Axis (X) = Number of visits in period X (1 visit/ 2 v. / 3 v. / etc.)
Values = Number of unique customers in period X
Period X = dynmaically selected

 

Two bar chart examples:
Period 2021.01.01 to 01.08

Period 2021.01.03 to 01.08

 

Best

Andreas

 

 

 

 

  •  

    Customers Count : =
    VAR _currentvisitcount =
    MAX ( 'Visit Count'[Visit Count] )
    VAR _customersvisitcount =
    FILTER (
    ADDCOLUMNS (
    SUMMARIZE ( Data, Customers[Customer_ID] ),
    "@visitcount", CALCULATE ( COUNTROWS ( Data ) )
    ),
    [@visitcount] = _currentvisitcount
    )
    RETURN
    COUNTROWS ( _customersvisitcount )

     

     

    Link to the sample pbix file 

     

4 Replies

  •  

    Customers Count : =
    VAR _currentvisitcount =
    MAX ( 'Visit Count'[Visit Count] )
    VAR _customersvisitcount =
    FILTER (
    ADDCOLUMNS (
    SUMMARIZE ( Data, Customers[Customer_ID] ),
    "@visitcount", CALCULATE ( COUNTROWS ( Data ) )
    ),
    [@visitcount] = _currentvisitcount
    )
    RETURN
    COUNTROWS ( _customersvisitcount )

     

     

    Link to the sample pbix file 

     

  • Thank you JiHwan Kim for your quick reply. 

     

    To understand it correctly, I have to create a new table with the unique ID's before I can start with the visualization. There is no other solution?

    • Jihwan_Kim's avatar
      Jihwan_Kim
      Icon for Super User rankSuper User

      Hi,

      Thank you for your feedback.

      I created the dimension table for CustomerID because

      - I do not know how your actual data model looks like. 

      - in order to make data model a bit more easy to understand.

       

      No need to create this dimension table.