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
Anonymous
Not applicable

Create New Table

There are two tables : New_Errors and New_Payments.

New Errors                                             New Payments

Accn_Id                                                    Accn_Id

Proc_code                                                Proc_code

Fixed_Date                                                Pmt_Date

                                                                  payors_id
I want to join two tables on keys Accn_Id and Proc_code and The new tables should have the coumns Accn_Id, Proc_code and their respective Fixed_Date, Pmt_Date and payors_id. Later I want to find the Avg DatedDiff (Fixed_Date, Pmt_Date). Can someone please help me write a Dax query to create the new table? I have used the below SQL Query to do the same in SQL.
WITH CTE AS (
SELECT P.[accn_id], E.[proc_code], MAX(P.[pmt_date]) AS PmtDate, MAX(E.[fix_date]) as FixDate
FROM [dbo].[New_Errors] AS E
JOIN [dbo].[New_Payments] AS P ON E.[accn_id] = P.[accn_id] AND E.[proc_code] = P.[proc_code]
WHERE E.[fix_date] <> 'NULL'
GROUP BY P.[accn_id], E.[proc_code]
)
SELECT [proc_code] , AVG(DATEDIFF(DAY, PmtDate, FixDate)) AS avg_date_diff
FROM CTE
GROUP BY [proc_code] ;
Thank you in advance.


1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

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

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.