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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
athoslar
Regular Visitor

Como relacionar tabelas usando índices acumulados no Power BI?

Olá, comunidade do Microsoft Fabric!

Estou enfrentando um problema no Power BI e gostaria de ajuda para resolver a seguinte situação:

Tenho duas tabelas com dados de produção e preciso relacioná-las usando índices acumulados. As tabelas são parecidas com as seguintes:

ChaveUnicaUnidades ProduzidasValorAcumuladoData
aaa2201/01/2024
bbb4601/01/2024
ccc3901/01/2024
ddd51401/01/2024
eee3302/01/2024
fff2502/01/2024
ggg3802/01/2024
hhh1103/01/2024
iii2303/01/2024
jjj2503/01/2024



Onde a coluna ValorAcumulado foi criada para facilitar a ligação

e:

DataChaveProdutoindice
01/01/2024a1
01/01/2024b2
01/01/2024c3
01/01/2024d4
01/01/2024e5
01/01/2024f6
01/01/2024g7
01/01/2024h8
01/01/2024i9
01/01/2024j10
01/01/2024a11
01/01/2024b12
01/01/2024c13
01/01/2024d14
02/01/2024e1
02/01/2024f2
02/01/2024g3
02/01/2024h4
02/01/2024i5
02/01/2024j6
02/01/2024a7
02/01/2024b8



onde cada linha é uma unidade produzida, no caso a coluna indice apenas mostra a ordem em que os produtos foram produzidos.
A idéia seria filtrar os produtos produzidos pela ordem em que foram feitos, e linkar com a tabela que contém chaveunica e unidades produzidas. O valor acumulado também me diz a ordem em que esses produtos foram feitos. O resultado seria desta forma :

DataChaveProdutoindiceChaveUnica
01/01/2024a1aaa
01/01/2024b2aaa
01/01/2024c3bbb
01/01/2024d4bbb
01/01/2024e5bbb
01/01/2024f6bbb
01/01/2024g7ccc
01/01/2024h8ccc
01/01/2024i9ccc
01/01/2024j10ddd
01/01/2024a11ddd
01/01/2024b12ddd
01/01/2024c13ddd
01/01/2024d14ddd
02/01/2024e15eee
02/01/2024f16eee
02/01/2024g17eee
02/01/2024h18fff
02/01/2024i19fff
02/01/2024j20ggg
02/01/2024a21ggg
02/01/2024b22ggg


porém estou com dificuldades em entender como fazer isso em powerbi

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

Hi,@athoslar 

Regarding the issue you raised, my solution is as follows:

1.First, you'll need to use PowerQuery to add an index column to the table, either starting with 0 or 1.

vlinyulumsft_0-1720071809942.png

2.Then create a custom column with the following code:

vlinyulumsft_1-1720071821562.png

vlinyulumsft_2-1720071826701.png

List.Sum(List.FirstN(#"Added Index"[Unidades Produzidas],[Index]+1))

3.Next, the result table is generated with copy table(2):

vlinyulumsft_3-1720071869569.png

4.Also generate an index column in the results table:

vlinyulumsft_4-1720071882290.png

5.Use a merge query to merge two tables:

vlinyulumsft_5-1720071897295.png

vlinyulumsft_6-1720071914959.png

6.Expand what you want:

vlinyulumsft_7-1720071938265.png

7.Click the button as shown below

vlinyulumsft_8-1720071956453.png

8.After removing unnecessary columns, the end result is as follows:

vlinyulumsft_9-1720071971379.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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-linyulu-msft
Community Support
Community Support

Hi,@athoslar 

Regarding the issue you raised, my solution is as follows:

1.First, you'll need to use PowerQuery to add an index column to the table, either starting with 0 or 1.

vlinyulumsft_0-1720071809942.png

2.Then create a custom column with the following code:

vlinyulumsft_1-1720071821562.png

vlinyulumsft_2-1720071826701.png

List.Sum(List.FirstN(#"Added Index"[Unidades Produzidas],[Index]+1))

3.Next, the result table is generated with copy table(2):

vlinyulumsft_3-1720071869569.png

4.Also generate an index column in the results table:

vlinyulumsft_4-1720071882290.png

5.Use a merge query to merge two tables:

vlinyulumsft_5-1720071897295.png

vlinyulumsft_6-1720071914959.png

6.Expand what you want:

vlinyulumsft_7-1720071938265.png

7.Click the button as shown below

vlinyulumsft_8-1720071956453.png

8.After removing unnecessary columns, the end result is as follows:

vlinyulumsft_9-1720071971379.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

 

 

 

 

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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