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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Daniff
Helper I
Helper I

Sales in many periods

Good afternoon, I need your help. imagine you have a customer sales table and a manager history table for those customers with customer start and end data. imagine a manager who has 2 periods with a client. How can I make a dynamic formula for him to provide me as sales of this manager in the periods of the history table? Thank you very much

08F47EB7-B1B2-4618-AFBE-AD7F8A71D406.jpeg

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

Hi @Daniff ,

According to your description, here's my solution.

1. Create a date table, the date range should cover the dates that appear in the sample.

Date = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))

2. Create a calculated column in the History Manager table.

End Column = IF('History Manager'[End Date]=BLANK(),TODAY(),'History Manager'[End Date])

3. Create a new table.

vkalyjmsft_0-1646705937449.png

Table =
FILTER (
    GENERATE ( 'History Manager', 'Date' ),
    'Date'[Date] >= 'History Manager'[Start Date]
        && 'Date'[Date] <= 'History Manager'[End Column]
)

4. Create a measure.

Measure =
VAR _Client =
    SELECTCOLUMNS (
        FILTER (
            'History Manager',
            'History Manager'[Manager] = MAX ( 'History Manager'[Manager] )
        ),
        "Client", 'History Manager'[Client]
    )
VAR _T =
    FILTER (
        ALL ( 'Sell Out' ),
        'Sell Out'[Client]
            IN _Client
                && 'Sell Out'[Date]
                    IN SELECTCOLUMNS (
                        FILTER (
                            'Table',
                            'Table'[Client] IN SELECTCOLUMNS ( 'Sell Out', "Client", 'Sell Out'[Client] )
                        ),
                        "Date", 'Table'[Date]
                    )
    )
RETURN
    CALCULATE ( SUM ( 'Sell Out'[Sell Out] ), _T )

Get the expected result.

vkalyjmsft_1-1646706249206.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Daniff ,

According to your description, here's my solution.

1. Create a date table, the date range should cover the dates that appear in the sample.

Date = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))

2. Create a calculated column in the History Manager table.

End Column = IF('History Manager'[End Date]=BLANK(),TODAY(),'History Manager'[End Date])

3. Create a new table.

vkalyjmsft_0-1646705937449.png

Table =
FILTER (
    GENERATE ( 'History Manager', 'Date' ),
    'Date'[Date] >= 'History Manager'[Start Date]
        && 'Date'[Date] <= 'History Manager'[End Column]
)

4. Create a measure.

Measure =
VAR _Client =
    SELECTCOLUMNS (
        FILTER (
            'History Manager',
            'History Manager'[Manager] = MAX ( 'History Manager'[Manager] )
        ),
        "Client", 'History Manager'[Client]
    )
VAR _T =
    FILTER (
        ALL ( 'Sell Out' ),
        'Sell Out'[Client]
            IN _Client
                && 'Sell Out'[Date]
                    IN SELECTCOLUMNS (
                        FILTER (
                            'Table',
                            'Table'[Client] IN SELECTCOLUMNS ( 'Sell Out', "Client", 'Sell Out'[Client] )
                        ),
                        "Date", 'Table'[Date]
                    )
    )
RETURN
    CALCULATE ( SUM ( 'Sell Out'[Sell Out] ), _T )

Get the expected result.

vkalyjmsft_1-1646706249206.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

@Daniff ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

refer if this can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

or

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

 

OR

SCD
Guyinacube - https://www.youtube.com/watch?v=tKeaQpWynzg

https://www.youtube.com/watch?v=E1ZABKBpkdg

https://www.zartis.com/scd-implementation-with-temporal-tables-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, thank you very much for your reply. Attached I send the power bi project to be able to test. We have 2 tables. one with the history of clients by manager and respective periods. The second table is the customer sales with the date. The final result I want is a table per manager with the total sales (just add the sales in the period that each manager had the customer). Can you help? Thank you very much

 

Power BI - https://we.tl/t-unL4YALu3d

Hello please help me

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.