Forum Discussion
mihaigm
1 year agoHelper I
Calculated column with latest value from another table
Hello dear friends! I'm working on a project in PowerBi and just to simplify the example, I'm having 2 tables, one for the sales and the other for the sales persons. In the "Sales Persons" table, "M...
- Anonymous1 year ago
Hi mihaigm ,
Thanks for danextian reply.
You can create two calculate columns to achieve this
In sales person tableNextDate = VAR CurrentCompany = [Company] VAR CurrentArea = [Area] VAR CurrentProd = [Prod] VAR CurrentDate = [Date] VAR NextDate = MINX( FILTER( 'Sales person', 'Sales person'[Company] = CurrentCompany && 'Sales person'[Area]= CurrentArea && 'Sales person'[Prod] = CurrentProd && 'Sales person'[Date] > CurrentDate ), 'Sales person'[Date] ) RETURN IF(ISBLANK(NextDate), DATE(2025, 12, 31), NextDate)In Sales table
Seller Name = VAR CurrentDate = 'Sales'[Date] VAR CurrentProd = 'Sales'[Prod] VAR CurrentArea = Sales[Area] VAR CurrentCompany = 'Sales'[Company] RETURN CALCULATE( MAX('Sales person'[Seller Name]), FILTER( 'Sales person', 'Sales person'[Prod] = CurrentProd && 'Sales person'[Company] = CurrentCompany && 'Sales person'[Area] = CurrentArea && 'Sales person'[Date] <= CurrentDate && 'Sales person'[NextDate] >= CurrentDate ) )Final output
Best regards,
Albert HeIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Anonymous
1 year agoNot applicable
Hi mihaigm ,
Thanks for danextian reply.
You can create two calculate columns to achieve this
In sales person table
NextDate =
VAR CurrentCompany = [Company]
VAR CurrentArea = [Area]
VAR CurrentProd = [Prod]
VAR CurrentDate = [Date]
VAR NextDate =
MINX(
FILTER(
'Sales person',
'Sales person'[Company] = CurrentCompany &&
'Sales person'[Area]= CurrentArea &&
'Sales person'[Prod] = CurrentProd &&
'Sales person'[Date] > CurrentDate
),
'Sales person'[Date]
)
RETURN
IF(ISBLANK(NextDate), DATE(2025, 12, 31), NextDate)
In Sales table
Seller Name =
VAR CurrentDate = 'Sales'[Date]
VAR CurrentProd = 'Sales'[Prod]
VAR CurrentArea = Sales[Area]
VAR CurrentCompany = 'Sales'[Company]
RETURN
CALCULATE(
MAX('Sales person'[Seller Name]),
FILTER(
'Sales person',
'Sales person'[Prod] = CurrentProd &&
'Sales person'[Company] = CurrentCompany &&
'Sales person'[Area] = CurrentArea &&
'Sales person'[Date] <= CurrentDate &&
'Sales person'[NextDate] >= CurrentDate
)
)
Final output
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
mihaigm
1 year agoHelper I
Hello Anonymous and Thank you so much for your help!!! It works perfectly fine!!!! 😊😎Now I'm playing around with more complex formulas!!! Wish you a great evening!! and a great Week, too!!