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

research column to column

Hello everyone,

I would like to calculate the quantity we ve sold for each item we have (on the last 12 months).

But some reference has changed.

 

So, if there is no old item ref, I just would like the sum that I made.

And if there is an old item no, I would calculate the quantity of the item no + the quantity of the old item no

 

Item n°   Old item n°   Qty

X12            TU                2

51            VE                1

TU1            /                  1

VE            /                  1

 

Exepected results:

X12 => 2

TU1 => 3

51 => 1

VE => 2

1 ACCEPTED SOLUTION

Hi @Anonymous,

Item n°   Old item n°   Qty

X12            TU1                2

51            VE                1

TU1            /                  1

TU1          /                   2

VE            /                  1

51             VE               2

 

You can new a calculated table.

Tab_2 =
VAR temptab1 =
    SUMMARIZE ( Tab_1, Tab_1[Old item n], "Qty1", SUM ( Tab_1[Qty] ) )
RETURN
    SUMMARIZE (
        Tab_1,
        Tab_1[Item n],
        "Total Qty", SUM ( Tab_1[Qty] )
            + SUMX ( FILTER ( temptab1, [Old item n] = EARLIER ( Tab_1[Item n] ) ), [Qty1] )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please add a calculated column:

Sum Qty = Tab_1[Qty]+LOOKUPVALUE(Tab_1[Qty],Tab_1[Old item n],Tab_1[Item n])

1.PNG

 

Regards,

Yuliana Gu

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

Sorry,

This is not so simple. LOOKUPVALUE doesn't work.

 

My exemple is too simple. Item n° is not a primary key (not a UNIQUE)

 

This is closer than the reality :

Item n°   Old item n°   Qty

X12            TU1                2

51            VE                1

TU1            /                  1

TU1          /                   2

VE            /                  1

51             VE               2

 

Expected results :

X12 => 2

51 => 4

TU1 => 3

VE => 1

Hi @Anonymous,

Item n°   Old item n°   Qty

X12            TU1                2

51            VE                1

TU1            /                  1

TU1          /                   2

VE            /                  1

51             VE               2

 

You can new a calculated table.

Tab_2 =
VAR temptab1 =
    SUMMARIZE ( Tab_1, Tab_1[Old item n], "Qty1", SUM ( Tab_1[Qty] ) )
RETURN
    SUMMARIZE (
        Tab_1,
        Tab_1[Item n],
        "Total Qty", SUM ( Tab_1[Qty] )
            + SUMX ( FILTER ( temptab1, [Old item n] = EARLIER ( Tab_1[Item n] ) ), [Qty1] )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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.