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
alderete-tomas
Frequent Visitor

Combine tables within different date between them

The model has several queries where there are three that I need to match. First, a table of people containing ID+(yearmonth) as a unique ID but it is not connected to calendar as the table people has no date column; Second, a table containing salary by people (the same key that People's table) connected to People and Calendar; the third, Attendance connected by key to People and by date to Calendar. I need to get the sumproduct between salary and certain states of attendance by people, to get the ammount paid, and then, do the same but get the same attendance's states for the previous month.

To be more exact, these are the measures:
 

1. BI_HC = SUMX(SUMMARIZE(Personas,Personas[Key],"BIHC",[Remuneración (Sin Horas Extras) Mes Ant]*[Operativos]),[BIHC])
Where [Operativos] get the sum of certain attendance states of actual month, [Remuneración (Sin Horas Extras) Mes Ant] retrieving salaries but for the previous month.

2. 
BI_HC Mes Ant =SUMX(SUMMARIZE(Personas,Personas[Key],"BIHCA",[Remuneración (Sin Horas Extras) Mes Ant]*[Operativos Mes Ant]),[BIHCA])
This one does the same that the other one but both measures used ([Remuneración (Sin Horas Extras) Mes Ant] and [Operativos Mes Ant]) are retrieved from previous month. 
 
 The problem is that N°1 doesn't return a number, while the second does. How can I match different measures with different month, by People? Or it is not possible?
 
 
Captura de pantalla 2023-01-12 074443.png



1 REPLY 1
johnt75
Super User
Super User

Its not a good idea to add columns using SUMMARIZE, see this article from SQLBI.

Instead, use ADDCOLUMNS, e.g.

BI_HC =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( Personas, Personas[Key] ),
        "BIHC", [Remuneración (Sin Horas Extras) Mes Ant] * [Operativos]
    ),
    [BIHC]
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.