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

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.

Reply
palabi
Frequent Visitor

Select multiple items for filter in slicer

Hi! I have a table with the inventory of my products, and also the sales of each product.

In order to know how much inventory I have left before running out, I calculate how much inventory I have this week, and divide it by how many sales in average I had in the past.


So, the formula is:
Inventory / Average weekly sales

The result is a number that tells me how many weeks I still can sell without needing more inventory. If it is too low I have to get more product, if it is too high, I may consider a price drop.

 

This is my problem:

To calculate the average weekly sales, I use the sales of the last 4 to 20 weeks (the exact number depends on each product). This is no problem when I want to see my result of the current week. But if I need to checks last week´s, or any other week in the past, I have to select that week on the slicer, and manually select the other pasts weeks manually, this has created many trouble and many errors by humans.


What I need is some way to select in one click 4 to 20 weeks, prior to the week from where I need the result.

For example, I have weeks 1 to 20, I want to calculate the average using the last 4 weeks for each week. If I select “week15” on a slicer, I need to also select week14, week13, week12 and week11. Or if I select “week10” the filter should also include “week9, week8, week7 and week6”.


Any help or ideas on how to do this?

Thanks very much

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

hi,@palabi

you may try to add a measure to calculate the average using the last 4 weeks for each week like as below:

Last 4 weeks AVERAGE = 
VAR currWeek =
    MAX ( StoreSales[Week id] )
RETURN
    CALCULATE (
        AVERAGE(StoreSales[Qty]),
        FILTER (
            ALL(  StoreSales ),
            StoreSales[Week id]
                IN GENERATESERIES ( MAX ( currWeek - 4, 1 ), currWeek-1, 1 )

Result:

2.PNG

after selecting one week 

3.PNG

Here is DEMO ,please try it

https://www.dropbox.com/s/qde8w728om35fcq/Select%20multiple%20items%20for%20filter%20in%20slicer.pbi...

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
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-lili6-msft
Community Support
Community Support

hi,@palabi

you may try to add a measure to calculate the average using the last 4 weeks for each week like as below:

Last 4 weeks AVERAGE = 
VAR currWeek =
    MAX ( StoreSales[Week id] )
RETURN
    CALCULATE (
        AVERAGE(StoreSales[Qty]),
        FILTER (
            ALL(  StoreSales ),
            StoreSales[Week id]
                IN GENERATESERIES ( MAX ( currWeek - 4, 1 ), currWeek-1, 1 )

Result:

2.PNG

after selecting one week 

3.PNG

Here is DEMO ,please try it

https://www.dropbox.com/s/qde8w728om35fcq/Select%20multiple%20items%20for%20filter%20in%20slicer.pbi...

 

Best Regards,

Lin

 

 

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

Thank you very much for your help.
I´m afraid I dont fully understand the solution, but it seems to work!
Let me have a couple of days to learn a little about the functions please.

 

thanks again!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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