Forum Discussion
group data by minimum value
- Anonymous5 years ago
Hi nicolasvc
I think you want to create a calcualte table to show frist week of each month based on "Table 1".
Try my code.
Table 2 = VAR _T1 = SUMMARIZE ( 'Table 1', 'Table 1'[Store], 'Table 1'[Year], 'Table 1'[Month], "MinWeekEachMonth", CALCULATE ( MIN ( 'Table 1'[Week] ), FILTER ( 'Table 1', AND ( 'Table 1'[Year] = EARLIER ( 'Table 1'[Year] ), 'Table 1'[Month] = EARLIER ( 'Table 1'[Month] ) ) ) ) ) VAR _T2 = ADDCOLUMNS ( _T1, "Sales", CALCULATE ( SUM ( 'Table 1'[Sales] ), FILTER ( 'Table 1', 'Table 1'[Store] = EARLIER ( [Store] ) && 'Table 1'[Year] = EARLIER ( [Year] ) && 'Table 1'[Month] = EARLIER ( [Month] ) && 'Table 1'[Week] = EARLIER ( [MinWeekEachMonth] ) ) ) ) RETURN _T2Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nicolasvc try this, assuming every month has a week 1 record.
Table 2 =
FILTER( 'Table 1', 'Table 1' [week] = 1 )
✨ Follow us on LinkedIn
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to 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.⚡
I forgot to specify that the week corresponds to the number of the week of the year 😞