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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
sanjay009
Helper III
Helper III

Conditional query help fro dynamic column names

i have a table with columns

ID TXT102 TXT345 TXT567   NewColumn

1    No         yes          No         yes

2    yes        No          yes          yes

3    No        No           No          No

 

every month the after TXT the numbers changes.Want a conditional new column has above if any coumn contains (txt) = "yes" display yes else no.

 

 

4 REPLIES 4
v-eqin-msft
Community Support
Community Support

Hi @sanjay009 ,

According to my understand, the column names are constantly changing except the ID column ,right?

 

You could follow these steps or take a look at  my pbix file here.

1. Select the ID column and click Transpose ,then "Use first row as headers".

2. Add a Index column (used as Matrix rows )

3. Use the formula:

ID is 1 =
VAR _flag =
    IF ( MAX ( 'Table2'[1] ) = "yes", 1, 0 )
VAR _total =
    IF ( _flag > 0, "yes", "No" )
RETURN
    IF ( HASONEVALUE ( Table2[Index] ), MAX ( 'Table2'[1] ), _total )

9.14.1.1.PNG

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

 

Ashish_Mathur
Super User
Super User

Hi,

Will there always be only 3 TXT column?  Also, as Amit has suggested, are you agreeable to using the "Unpivot other columns" feature?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@sanjay009 , I think the best way select ID and use unpivot other columns .

 

Then you will have a column like Txt and Value( Yes/No)

 

Then you can have a new column

if(countx(filter(Table, [Id] = earlier([id]) && [TXT] ="yes" ), [Id])+0 >0, "Yes","No")

 

You can use that in Matrix now

Greg_Deckler
Super User
Super User

@sanjay009 Columns changing names is not a good thing at all. Is there any way you can not promote headers on import?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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