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
karun_r
Employee
Employee

Tracking historical values with snowflake pattern

Hi,

 

I am doing a POC where I am trying to track historical values using snowflake pattern. Scenario is something like below

 

I'll have a customer who buys something thru an Account Manager. Customer can switch between Account Managers. What I am interested to see is, to have the customer name, all revenue from that customer thru all current/past acccount managers and the name of the current manager (it could repeat across all rows). 

 

Attached the sample pbix file. (link below).  I am trying to follow a pattern that is mentioned in this book "Agile Data Warehouse Design" by Lawrence Corr. I was not sure if the pattern mentioned in the book was achievable so thought of checking it myself and it seems like I am stuck in implementing this properly

 

karun_r_0-1609980348501.png

karun_r_1-1609980361615.png

 

https://1drv.ms/u/s!AmE9ILAWJzWtgoYjoJGmYRTePU_0Nw?e=E2pV3K

 

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @karun_r ,

 

According to my understanding, you want to get all the name of all managers and the lastest manager of each customer,right?

You could use the following formula:

Manager Name =
LOOKUPVALUE (
    AccountManager[Name],
    'AccountManager'[AccountManagerID], [AccountManagerID]
)

 

All Managers =
CONCATENATEX (
    FILTER ( 'Fact', 'Fact'[CustomerID] = EARLIER ( 'Fact'[CustomerID] ) ),
    [Manager Name],
    ",",
    [Date], ASC
)

 

The Last/Current Manager =
CALCULATE (
    MAX ( 'Fact'[Manager Name] ),
    FILTER (
        'Fact',
        'Fact'[CustomerID] = EARLIER ( 'Fact'[CustomerID] )
            && 'Fact'[Date]
                = CALCULATE ( MAX ( 'Fact'[Date] ), ALLEXCEPT ( 'Fact', 'Fact'[CustomerID] ) )
    )
)

The final table output is shown below:

1.11.1.1.PNG

 

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @karun_r ,

 

According to my understanding, you want to get all the name of all managers and the lastest manager of each customer,right?

You could use the following formula:

Manager Name =
LOOKUPVALUE (
    AccountManager[Name],
    'AccountManager'[AccountManagerID], [AccountManagerID]
)

 

All Managers =
CONCATENATEX (
    FILTER ( 'Fact', 'Fact'[CustomerID] = EARLIER ( 'Fact'[CustomerID] ) ),
    [Manager Name],
    ",",
    [Date], ASC
)

 

The Last/Current Manager =
CALCULATE (
    MAX ( 'Fact'[Manager Name] ),
    FILTER (
        'Fact',
        'Fact'[CustomerID] = EARLIER ( 'Fact'[CustomerID] )
            && 'Fact'[Date]
                = CALCULATE ( MAX ( 'Fact'[Date] ), ALLEXCEPT ( 'Fact', 'Fact'[CustomerID] ) )
    )
)

The final table output is shown below:

1.11.1.1.PNG

 

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@karun_r , Yet to check the file. But As in power Bi we prefer star schema, I would merge the Account manager name from the employee table by joining account manager ID with employee ID (Column name may differ)

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Or copy the name from employee table in DAX using one the three approches - https://www.youtube.com/watch?v=czNHt7UXIe8

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.