Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

Pre l Post Event Filtering and Calculations based on user selected criteria

Hi Everyone, 

 

Relatively new to PBI and I am attempting to create a sales dashboard using the last 52 week sales data by week, and I need to provide visibility into the sales data separated into a "Pre" and "Post" group of weeks based on a user defined week.  This allows leadership to view how products performed leading up to, and then following a planogram change at the store level.

 

One challenge is that my weeks are deisgnated as YYYYWW, not in a dates table.  ie. 202101-2020152 would be my week range for calnedar year 2021.  This column is formated as a text column.

 

Any insight or help on how to build this visualization would be appreciated!

 

 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you want to display the data of 202102 and 202104 when you select 202103? 

 

vkkfmsft_1-1628750558487.pngvkkfmsft_2-1628750578083.png

 

If so, you need to create a new table, and then use the following measure.

 

vkkfmsft_3-1628750831725.png

Measure = 
CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        'Table',
        'Table'[Week] in { MAX('WeekNum'[Week]) - 1, MAX('WeekNum'[Week]) + 1 }
    )
)

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you want to display the data of 202102 and 202104 when you select 202103? 

 

vkkfmsft_1-1628750558487.pngvkkfmsft_2-1628750578083.png

 

If so, you need to create a new table, and then use the following measure.

 

vkkfmsft_3-1628750831725.png

Measure = 
CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        'Table',
        'Table'[Week] in { MAX('WeekNum'[Week]) - 1, MAX('WeekNum'[Week]) + 1 }
    )
)

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , what you want to compare is not clear. We have move year week, year and week into a new table (say Date)

 

 and we can create week rank and these measures are possible

 

Week Rank = RANKX(all("Date"),"Date"[Year Week],,ASC,Dense) //YYYYWW format
measures
This Week = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Week Rank]=max("Date"[Week Rank])))
Last Week = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Week Rank]=max("Date"[Week Rank])-1))
Last year Week= CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Week Rank]=(max("Date"[Week Rank]) -52)))

 

YTD= CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Year]=max("Date"[Year]) && "Date"[Week] <= Max("Date"[Week]) ))
LYTD = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Year]=max("Date"[Year])-1 && "Date"[Week] <= Max("Date"[Week])))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.