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
Abevann
Helper III
Helper III

I have to mix two tables and get a result by week

Guys,

 

I have been working on a dashboard and got stuck; I have a couple of tables (SQL query) 

DateInputOutput
20/01/2021 1
22/01/2021 1
02/02/2021 0
12/02/2021 1
08/03/2021 2
18/03/2021 1
23/03/2021 1
26/03/2021 1

 

DateMonthly stock
01/01/20218
01/02/20216
01/03/20215
01/04/20210

 

On first table, I have the input and output from warehouse; in second one, I have the stock in warehouse. What I am looking for, is to get a table with the stock and substract the inputs or outputs of the warehouse as on attached table:

Product codeYear-weekInputOutputMonthy stockWeekly stock
UC48C22021-01  88
UC48C22021-04 2 6
UC48C22021-06 066
UC48C22021-07 1 5
UC48C22021-10  55
UC48C22021-11 2 3
UC48C22021-12 1 2
UC48C22021-13 2 0

 

Any suggestion for this issue?

 

Thanks a lot, regards,

Abelardo

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Abevann 

 

First, you need to append two tables in power query.

vzhangti_0-1639028480049.png

 

Then use the following calculation column to output the results you want.

Week = WEEKNUM([Date],1)
Weekly stock =
MAX ( Append1[Monthly stock] )
    - CALCULATE (
        SUM ( Append1[Output] ),
        FILTER ( Append1, [Week] <= EARLIER ( Append1[Week] ) )
    )
Year-week = YEAR([Date])&"-"&[Week]

vzhangti_1-1639028672590.png

 

The "week" column needs to be reserved, otherwise the view cannot be sorted.

vzhangti_2-1639028720570.png

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Abevann 

 

First, you need to append two tables in power query.

vzhangti_0-1639028480049.png

 

Then use the following calculation column to output the results you want.

Week = WEEKNUM([Date],1)
Weekly stock =
MAX ( Append1[Monthly stock] )
    - CALCULATE (
        SUM ( Append1[Output] ),
        FILTER ( Append1, [Week] <= EARLIER ( Append1[Week] ) )
    )
Year-week = YEAR([Date])&"-"&[Week]

vzhangti_1-1639028672590.png

 

The "week" column needs to be reserved, otherwise the view cannot be sorted.

vzhangti_2-1639028720570.png

 

Best Regards,

Community Support Team _Charlotte

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

 

 

 

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.