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
nujkram
Regular Visitor

Adding records in new table based on distinct row with computation

Good day everyone, I'm new with Power BI just wanted to ask how can I add the distinct items from one table into another.

 

I wanted to save all the distinct group_items in [Items] Table to [Duration] Table and compute the total created time for each group_items. See sample image below. I've been searching all day now still no chance.

 

Untitled-1.jpg

 

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

Hi @nujkram

First in query editor

add two custom columns (Add Column->Custom Column)

Custom=DateTime.Time([created])

Custom.1= #time(Time.Hour([Custom]),0,0)

6.png

7.png

 

Second in Data View, create two calculated columns

duration = [Custom]-[Custom.1]

sumduration = CALCULATE(SUM(Sheet5[duration]),ALLEXCEPT(Sheet5,Sheet5[items]))

8.png

 

Second create a new table and create a calculated column in this new table

Table = SUMMARIZE(Sheet5,Sheet5[items],Sheet5[sumduration])

id = RANKX(ALL('Table'),'Table'[items],,ASC)

9.png

 

 

Best regards

maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @nujkram

First in query editor

add two custom columns (Add Column->Custom Column)

Custom=DateTime.Time([created])

Custom.1= #time(Time.Hour([Custom]),0,0)

6.png

7.png

 

Second in Data View, create two calculated columns

duration = [Custom]-[Custom.1]

sumduration = CALCULATE(SUM(Sheet5[duration]),ALLEXCEPT(Sheet5,Sheet5[items]))

8.png

 

Second create a new table and create a calculated column in this new table

Table = SUMMARIZE(Sheet5,Sheet5[items],Sheet5[sumduration])

id = RANKX(ALL('Table'),'Table'[items],,ASC)

9.png

 

 

Best regards

maggie

Thank you so much @v-juanli-msft (maggie). Works like a charm!

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.