Forum Discussion
Lookup function
- 2 years ago
Peter,
Try this instead (instead of matching on the exact date, it matches on the month):
VALUE = VAR SelOperation = SELECTEDVALUE ( ProductionData[OPERATION] ) VAR SelMonth = MONTH ( SELECTEDVALUE ( ProductionData[REPORTED DATE] ) ) VAR Result = CALCULATE ( SUM ( Table2[Value] ), Table2[OPERATION] = SelOperation, MONTH ( Table2[Table Date] ) = SelMonth ) RETURN Result
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
Hi Wilson,
yes sure. the logic is very simple:
In table "ProductionData" I have the data about lot fo PO´s with specific numbers. Each PO has specific REPORTED DATE. And from this specific reported date first of all I need take number/name of the month and get the VALUE from the Table2 which will exactly match with the data from ProductionTable (project, operation, year...) AND IT WILL TAKE THE VALUE FROM SPECIFIC COLUMN BASED ON THE NUMBER/NAME OF THE MONTH.
Example: if PO is reported on 12.1.2024, formula has to return the Value from column 1 - which means January. If PO is reported on 19.2.2024, formula has to return the Value from column 2 - which means February.....
But basically this is already working in model which you provide, but only isssue is that from some reasons it make a SUM of the value...
P.
Peter,
Try this instead (instead of matching on the exact date, it matches on the month):
VALUE =
VAR SelOperation = SELECTEDVALUE ( ProductionData[OPERATION] )
VAR SelMonth = MONTH ( SELECTEDVALUE ( ProductionData[REPORTED DATE] ) )
VAR Result =
CALCULATE (
SUM ( Table2[Value] ),
Table2[OPERATION] = SelOperation,
MONTH ( Table2[Table Date] ) = SelMonth
)
RETURN Result
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
- Peter_20202 years ago
Helper III
Hi Wilson, now it works. Thank you for your help.