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
minseon
Frequent Visitor

Creating Table B from Table A with Specific Conditions and Aggregation

Hi all
i have issue during makeing new table

-------

Table A has columns ITEM_CD, B_CD, DEPT_CD, C_NO, CREATED_AT, and MASK_YN. I want to create a new table B from this table with the following conditions.

1. table B has 4 columns. item_cd, B_CD, dept_cd, created_at
2.table A MASK_YN = 'Y'
3. the ITEM_CD column in B has the fastest CREATED_AT per ITEM_CD in A table
4. the ITEM_CD column in B must be a unique value
5. the B_CD, DEPT_CD, CREATED_AT column values in table B are the B_CD, DEPT_CD, CREATED_AT column values that map to the A table ITEM_CD column values based on the ITEM_CD extracted in step 3.

I tried below, but it didn't work
result tbale has duplicated item_cd
1.png

 

 

 

 

 

 

 

 

 

 

 

can you solve this issue??

thanks

 

1 ACCEPTED SOLUTION
ChiragGarg2512
Super User
Super User

@minseon Try the following DAX,

TableB = 
SUMMARIZE(
    FILTER(
        'TableA',
        'TableA'[MASK_YN] = "Y"
    ),
    [ITEM_CD],
    "B_CD", MAX('TableA'[B_CD]),
    "DEPT_CD", MAX('TableA'[DEPT_CD]),
    "CREATED_AT", CALCULATE(MAX('TableA'[CREATED_AT]), ALLEXCEPT('TableA', 'TableA'[ITEM_CD]))
)

View solution in original post

2 REPLIES 2
ChiragGarg2512
Super User
Super User

@minseon Try the following DAX,

TableB = 
SUMMARIZE(
    FILTER(
        'TableA',
        'TableA'[MASK_YN] = "Y"
    ),
    [ITEM_CD],
    "B_CD", MAX('TableA'[B_CD]),
    "DEPT_CD", MAX('TableA'[DEPT_CD]),
    "CREATED_AT", CALCULATE(MAX('TableA'[CREATED_AT]), ALLEXCEPT('TableA', 'TableA'[ITEM_CD]))
)

thank you 🙂

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.