Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi
Max Week Table below shows Month-Year and Max week of the month:
Month Year | Max/Last Week for the Month |
Jan-20 | 5 |
Feb-20 | 9 |
Mar-20 | 14 |
Apr-20 | 18 |
SALES table below:
| Product ID | | | Month Year | | | Sales | | | Data Snapshot week | |
P01 | Jan-20 | 500 | 5 |
P01 | Jan-20 | 1500 | 5 |
P02 | Feb-20 | 1000 | 9 |
P02 | Feb-20 | 2000 | 11 |
P01 | Jan-20 | 1500 | 13 |
P03 | Apr-20 | 4000 | 18 |
P03 | Jan-20 | 100 | 5 |
P03 | Jan-20 | 200 | 5 |
I want output to show a summarized table but Month-Year, Products and Sales SUM from the SALES table, but to be filtered by: IF Data Snapshot Week = Max/Last Week for the Month. Rows highlighted in RED should be removed from result table because they do not match Max week table.
Result:
| Product ID | | | Month Year | | | Sales SUM | | | Max/Last Week for the Month | |
P01 | Jan-20 | 2000 | 5 |
P02 | Feb-20 | 1000 | 9 |
P03 | Jan-20 | 300 | 5 |
P03 | Apr-20 | 4000 | 18 |
Thank you in advance.
Solved! Go to Solution.
Hi @mb0307 ,
First, create a relationship between Max Week and Sales table base on the field [Month Year], then create a calculated table as below:
Result =
SUMMARIZECOLUMNS (
'Sales'[Product ID],
'Sales'[Month Year],
'Max Week'[Max/Last Week for the Month],
'Sales',
"Sales SUM", CALCULATE (
SUM ( 'Sales'[Sales] ),
FILTER (
'Sales',
'Sales'[Data Snapshot week] = MAX ( 'Max Week'[Max/Last Week for the Month] )
)
)
)
Best Regards
Rena
@mb0307 set the relationship between these two tables on Max/Last week for the month
in the visual, use column from Max Week table and product, sales from 2nd table and it should work.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k Thanks but I would like to create a new table based on my query. I need to use the table to run some complex calculation.
Hi @mb0307 ,
First, create a relationship between Max Week and Sales table base on the field [Month Year], then create a calculated table as below:
Result =
SUMMARIZECOLUMNS (
'Sales'[Product ID],
'Sales'[Month Year],
'Max Week'[Max/Last Week for the Month],
'Sales',
"Sales SUM", CALCULATE (
SUM ( 'Sales'[Sales] ),
FILTER (
'Sales',
'Sales'[Data Snapshot week] = MAX ( 'Max Week'[Max/Last Week for the Month] )
)
)
)
Best Regards
Rena
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |