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
Anonymous
Not applicable

Weekly Forecast

Hi all! I need some help here...

I created a post similar to this one, but I think the information was incomplete.

I have a table called "Sales", which is updated every day with sales per store and product. The last date filled with data is yesterday! Example:

DateStoreProductQtTotal Sales
27/07/2020Store 1P21150
27/07/2020Store 1P33155
27/07/2020Store 2P32110
28/07/2020Store 1P11150
28/07/2020Store 2P12160
28/07/2020Store 2P21150
29/07/2020Store 1P33155
29/07/2020Store 2P32110
29/07/2020Store 3P1199,9
30/07/2020Store 2P12119,9
30/07/2020Store 2P21109,9
30/07/2020Store 3P13100

 

I need to create a chart with sales forecast per store, based on last days in this week / month / period of time. I would like to charte with stores in the rows, and date in the columns. For each date (if less than today), I must put the actual sales value. If the date is later, the field must be completed with the average of the last days in this chart (yellow marks in the table below). For security reasons, I can not put the true values...

Imagem1.jpg

 

How can I do this? There are some measure that I can create to do this?

Best regards,

Lucas

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi guys! I solve the problem doing this: - Create a table only with the stores values (Stores = VALUES(fVendas[store]) - Create a date table (d_Tempo = VAR DataMinima = MIN(fVendas[date]) VAR DataMaxima = MAX(fVendas[date])+365 RETURN CALENDAR(DataMinima,DataMaxima) - Create a new table summarizing daily sales per store; - Create a Forecast table joining store and d_tempo table(Forecast = CROSSJOIN(SELECTCOLUMNS(Store,"Loja",Store[Loja Correta]),SELECTCOLUMNS(d_Tempo,"Data",d_Tempo[Date])); - calculate the total sale in the actual week: Acumulado Semana TB1 = VAR SemanaAtual = 'Forecast'[Week Table 1] VAR LojaCorreta = 'Forecast'[Loja] VAR ActualYear = 'Forecast'[Ano] RETURN CALCULATE( SUM('Forecast'[Vendas do Dia]), FILTER( 'Forecast', 'Forecast'[Week Table 1] = SemanaAtual && 'Forecast'[Loja] = LojaCorreta && 'Forecast'[Ano] = ActualYear ) ) - And then, an if formula: Forecast Semanal = if( 'Forecast'[Data]

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi guys! I solve the problem doing this: - Create a table only with the stores values (Stores = VALUES(fVendas[store]) - Create a date table (d_Tempo = VAR DataMinima = MIN(fVendas[date]) VAR DataMaxima = MAX(fVendas[date])+365 RETURN CALENDAR(DataMinima,DataMaxima) - Create a new table summarizing daily sales per store; - Create a Forecast table joining store and d_tempo table(Forecast = CROSSJOIN(SELECTCOLUMNS(Store,"Loja",Store[Loja Correta]),SELECTCOLUMNS(d_Tempo,"Data",d_Tempo[Date])); - calculate the total sale in the actual week: Acumulado Semana TB1 = VAR SemanaAtual = 'Forecast'[Week Table 1] VAR LojaCorreta = 'Forecast'[Loja] VAR ActualYear = 'Forecast'[Ano] RETURN CALCULATE( SUM('Forecast'[Vendas do Dia]), FILTER( 'Forecast', 'Forecast'[Week Table 1] = SemanaAtual && 'Forecast'[Loja] = LojaCorreta && 'Forecast'[Ano] = ActualYear ) ) - And then, an if formula: Forecast Semanal = if( 'Forecast'[Data]
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I just created a sample pbix file for you, please check if that is what you want.

1. Create a Date table

2. Create Stores table

Stores = VALUES('Sales'[Store]) 

3. Create relationships for these two tables with Sales table

4. Create a measure and create a line chart (Axis: date field from Date table   Legend: Store field from Stores table  Values: measure)

Measure = 
VAR _avesaleofOdays =
    CALCULATE (
        AVERAGE ( 'Sales'[Total Sales] ),
        FILTER (
            ALL ( 'Sales' ),
            'Sales'[Store] = MAX ( 'Stores'[Store] )
                && 'Sales'[Date] <= TODAY ()
        )
    )
RETURN
    IF (
        MAX ( 'Date'[Date] ) > TODAY (),
        _avesaleofOdays,
        CALCULATE ( SUM ( 'Sales'[Total Sales] ) )
    )

Weekly Forecast.JPG

Best Regards

Rena

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

Can you expand on this?


@Anonymous wrote:

If the date is later, the field must be completed with the average of the last days in this chart (yellow marks in the table below). 

 


You need to be able to specify a formula for the forecast calculation. If you can, we should be able to make a measure that accounts for past and future.

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.