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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.