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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
iluvcoding_91
Helper I
Helper I

DAX calculated table to create employee sales buckets based on their hire date

Hey guys, I'm trying to create a DAX calculated table which sums up the sales for each employee based on their hire date, then places these sales into different buckets. For example, if Bob Dylan began working on 6/1/2021 his and his month 1 sales were $5,000, then this should go in column "D". If Hope Barron began working on 8/1/2021 and her first month sales were $6,000, then this amount should go into column "D". Then second month sales should go into column "E", etc. 

iluvcoding_91_0-1649709967198.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I created a sample pbix file in an expected way, but please check the below picture and the attached pbix file.

I tried to create a sample like below.

Picture1.png

 

New Table = 
VAR summarytable =
    SUMMARIZECOLUMNS (
        Employee[Employee],
        'Calendar'[End of Month],
        "@SalesAmount", SUM ( Sales[Sales] )
    )
VAR firstsalesmonthtable =
    ADDCOLUMNS (
        summarytable,
        "@firstsalesmonth",
            MINX (
                FILTER ( summarytable, Employee[Employee] = EARLIER ( Employee[Employee] ) ),
                'Calendar'[End of Month]
            )
    )
VAR monthdifftable =
    FILTER (
        ADDCOLUMNS (
            firstsalesmonthtable,
            "@monthdiff", DATEDIFF ( [@firstsalesmonth], 'Calendar'[End of Month], MONTH ) + 1
        ),
        [@monthdiff] <= 3
    )
VAR descriptiontable =
    ADDCOLUMNS (
        monthdifftable,
        "@description", LOOKUPVALUE ( 'Description'[Description], 'Description'[index], [@monthdiff] )
    )
RETURN
    SUMMARIZE (
        descriptiontable,
        Employee[Employee],
        [@description],
        [@SalesAmount]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I created a sample pbix file in an expected way, but please check the below picture and the attached pbix file.

I tried to create a sample like below.

Picture1.png

 

New Table = 
VAR summarytable =
    SUMMARIZECOLUMNS (
        Employee[Employee],
        'Calendar'[End of Month],
        "@SalesAmount", SUM ( Sales[Sales] )
    )
VAR firstsalesmonthtable =
    ADDCOLUMNS (
        summarytable,
        "@firstsalesmonth",
            MINX (
                FILTER ( summarytable, Employee[Employee] = EARLIER ( Employee[Employee] ) ),
                'Calendar'[End of Month]
            )
    )
VAR monthdifftable =
    FILTER (
        ADDCOLUMNS (
            firstsalesmonthtable,
            "@monthdiff", DATEDIFF ( [@firstsalesmonth], 'Calendar'[End of Month], MONTH ) + 1
        ),
        [@monthdiff] <= 3
    )
VAR descriptiontable =
    ADDCOLUMNS (
        monthdifftable,
        "@description", LOOKUPVALUE ( 'Description'[Description], 'Description'[index], [@monthdiff] )
    )
RETURN
    SUMMARIZE (
        descriptiontable,
        Employee[Employee],
        [@description],
        [@SalesAmount]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@iluvcoding_91 , I have done this for customers here. Do same for employee

Period Of Stay – Cohort Analysis: https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-3-Period-Of-Stay-Cohort-Anal...

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

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.