Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I would like to ask you for your help with following situation:
I have database with lot of data about the production orders (TABLE1). Each specific order has info about the project, operation number, reported date and I need to connect somehow these data with following table (TABLE2):
Expected output will looks like this:
It means that I need to define the formula which takes PO, OPERATION, PROJECT, YEAR, REPORTED MONTH from couple of connected tables (this is working now) and compare it with TABLE2 and if it match return VALUE which means column based on the reported month - january = column MONTH1, february = column MONTH2....
Thank you in advance for your help.
P.
Solved! Go to Solution.
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?)
Proud to be a Super User! | |
Hi Peter,
Can you please share a sample pbix file? (If you don't know how, please check the pinned thread in the forum.)
Proud to be a Super User! | |
Hey Peter,
Here's my updated file. I have the table below in my pbix.
However, I made a few very important updates to your data model to produce this result:
There is further data model optimization available but I did the minimum necessary to answer your question. If you will be working with data and data models in your career, I strongly suggest you go through this free course from SQL on data modeling basics. It helped me tremendously and I hope it can do the same for you! 🙂
----------------------------------
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?)
Proud to be a Super User! | |
Hi Wilson,
thank you for updated file and explanation of the changes you made. I tried to copy the same solution to my dataset. It works but measure "VALUE" give s me high values, example - expected value is 3 and I have 878.
I think that problem will be in this part of the formula:
Because if you have only one specific record with specific Project, Operation, Date it works well, but if you have more than one record it gives back the sum of these values what is wrong. I tried to replace the sum with other command but without the success.
Any idea how to fix it?
Thank you
P.
Peter,
What expression is correct instead of the highlighted obviously depends on how you want to aggregate the values. Can you provide an example of multiple records for a specific Project, Operation and Date and what your expected outcome is? I can't help further if you just say "the sum of these values is wrong". 🙂
Proud to be a Super User! | |
Hi Wilson,
sorry but I made a mistake in my report and that was the reasons why it doesn't work. Now it is fixed and it works. But still I have one issue: if the dates in table ProductionOrder and Table2 match, everything works correctly, but if they are different, it no longer works.
Is it possilble to set up the formula that if PO is reported 12.1.2024 it will take Value from column 1 wich means January?
Thank you for your help.
P.
Peter,
Sure, if you don't want it to filter by date at all, remove the SelDate variable and the second parameter in the CALCULATE function from the measure.
----------------------------------
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?)
Proud to be a Super User! | |
Now the value is calculated for all records, but it make a SUM of the value:
Peter,
I'm not exactly following what you're looking for instead of the original solution. I don't know what "Is it possilble to set up the formula that if PO is reported 12.1.2024 it will take Value from column 1 wich means January?" means. Can you use concrete examples to explain the logic?
Proud to be a Super User! | |
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?)
Proud to be a Super User! | |
Hi Wilson, now it works. Thank you for your help.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
73 | |
58 | |
35 | |
31 |
User | Count |
---|---|
99 | |
57 | |
56 | |
46 | |
40 |