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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ezz
New Member

DAX, SUMX BETWEEN DATES,TABLES

I have two tables;

 

1_client_rate_history;

2_getTimeLogs;

I have to calculate actual revenue per clΔ±ent=πΈπ‘šπ‘π‘™π‘œπ‘¦π‘’π‘’ π»π‘œπ‘’π‘Ÿπ‘  𝑠𝑝𝑒𝑛𝑑 π‘“π‘œπ‘Ÿ πΆπ‘™π‘–π‘’π‘›π‘‘βˆ—πΆπ‘™π‘–π‘’π‘›π‘‘ π‘…π‘Žπ‘‘π‘’ with considering rate_effective_date which giving to correct client rate for timelogs_date

please help me!!

 

1_client_rate_history;

ezz_1-1693999671636.png

 



2_getTimeLogs;

ezz_2-1693999707622.png

 



 

3_Result table must be like below;

ezz_0-1693999653150.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ezz ,

You can create a calculated column as below in table '2_getTimeLogs' to get it. What's the relationship between rate_effective_date and  timelogs_date? The data timelogs_date should be greater than rate_effective_date?

revenue =
VAR _rate =
    CALCULATE (
        MAX ( '1_client_rate_history'[client_rate] ),
        FILTER (
            '1_client_rate_history',
            '1_client_rate_history'[client_name] = '2_getTimeLogs'[type]
                && '1_client_rate_history'[project_name] = '2_getTimeLogs'[project_name]
                && '1_client_rate_history'[rate_effective_date] <= '2_getTimeLogs'[timelogs_date]
        )
    )
RETURN
    '2_getTimeLogs'[hours_spent] * _rate

If the above ones can't help you figure out, please provide some raw data in your 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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ezz ,

You can create a calculated column as below in table '2_getTimeLogs' to get it. What's the relationship between rate_effective_date and  timelogs_date? The data timelogs_date should be greater than rate_effective_date?

revenue =
VAR _rate =
    CALCULATE (
        MAX ( '1_client_rate_history'[client_rate] ),
        FILTER (
            '1_client_rate_history',
            '1_client_rate_history'[client_name] = '2_getTimeLogs'[type]
                && '1_client_rate_history'[project_name] = '2_getTimeLogs'[project_name]
                && '1_client_rate_history'[rate_effective_date] <= '2_getTimeLogs'[timelogs_date]
        )
    )
RETURN
    '2_getTimeLogs'[hours_spent] * _rate

If the above ones can't help you figure out, please provide some raw data in your 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

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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