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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rnagallatav
New Member

Need Help - Duplicate rows issue

We have a requirement in power BI to create a tabular visual with columns from table A (id,status,type,value) and columns from table B (S_Opening_date,S_Closer_date)

For this I need to create two calculated columns "S_Opening_date" and " S_Close_date",
1) Logic for "S_Opening_date" - From table B, "attribute title" = "open date", the date in "atrribute value" column should be displayed, if available
2) Logic for "S_close_date" - From table B, "attribute title" = "close date", the date in "atrribute value" column should be displayed, if available

I have written the following DAX :
S_opening_date = if( 'Table B'[attribute Title] = "open date", 'Table B'[attribute value])
S_close_date = if( 'Table B'[attribute Title] = "close date", 'Table B'[attribute value])


However, data is getting repeated multiple times after including the calculated columns in the table for rows that have date information available.

Please guide me on how to avoid the duplicate rows and what might be wrong in my approach. Refer the attached sample data

Sample data :

Table A:

ID Status TimezoneValueCurrencyType
A12ActiveAmerica5000USDRetail
B34inactiveAsia0USDRetail
C45ActiveAsia0USDRetail
D56ActiveAsia1000USDRetail
E67inactiveAmerica0USDTemplate

 

Table - B

IDattribute Titleattribute value
A12close date13-11-2020
B34project partner 
C45FOH area 
B34Project type 
E67FOH area 
B34open date02-02-2021
C45open date20-07-2020

 

Result :

rnagallatav_3-1645614179075.png

Appreciate your support.

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @rnagallatav ,

Here are the steps you can follow๏ผš

1. Enter the power query, Home โ€“ Merge Queries โ€“ Merge Queries as new โ€“ Left Out.

vyangliumsft_0-1646096788367.png

Result:

vyangliumsft_1-1646096788371.png

2. Create calculated column.

Index =
IF(
    'Merge1'[Table B.attribute Title]=BLANK()&&'Merge1'[Table B.attribute value]=BLANK(),0,
RANKX(FILTER(ALL(Merge1),'Merge1'[ID ]=EARLIER('Merge1'[ID ])&&'Merge1'[Status ]=EARLIER('Merge1'[Status ])),[Table B.attribute value],,DESC,Dense))

vyangliumsft_2-1646096788374.png

3. Put [Index] in Filter, is=1.

vyangliumsft_3-1646096788374.png

4. Result:

vyangliumsft_4-1646096788378.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @rnagallatav ,

Here are the steps you can follow๏ผš

1. Enter the power query, Home โ€“ Merge Queries โ€“ Merge Queries as new โ€“ Left Out.

vyangliumsft_0-1646096788367.png

Result:

vyangliumsft_1-1646096788371.png

2. Create calculated column.

Index =
IF(
    'Merge1'[Table B.attribute Title]=BLANK()&&'Merge1'[Table B.attribute value]=BLANK(),0,
RANKX(FILTER(ALL(Merge1),'Merge1'[ID ]=EARLIER('Merge1'[ID ])&&'Merge1'[Status ]=EARLIER('Merge1'[Status ])),[Table B.attribute value],,DESC,Dense))

vyangliumsft_2-1646096788374.png

3. Put [Index] in Filter, is=1.

vyangliumsft_3-1646096788374.png

4. Result:

vyangliumsft_4-1646096788378.png

 

Best Regards,

Liu Yang

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

HotChilli
Community Champion
Community Champion

There are no duplicate rows.  There's probably a relationship created on ID and there are 2 entries in Table B for some of the entries in Table A.

-----

To get what you want, I would use Table B as the dimension table and Table A as the Fact table.  It looks like you can Pivot (from the Transform menu) the 'attribute Title' in Table B to get the table you want.

You won't need the calculated columns anymore.

You can then make the relationship from Table B->Table A as 1:m and create the table visual.

--

That will probably work with the sample data but the real data may be more complex.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon โ€“ Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save โ‚ฌ200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.