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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
t4h4
Regular Visitor

Switching between two text columns

Hi community,

I have two tables called Article and Article7, they both have the same schema (Title, id..) but one is on full import mode and the other uses direct query. I'm creating a table visual in my report and I want it to switch between including the Title text field from Article and Article7 based on some measure I created that returns True or False (which act like a condition, if True the Title from Article , else Title from Article7). This seems challenging with DAX because DAX only returns single values and not whole columns, also Virtual tables use import mode and in this case I'm dealing with both Import and Direct Query.

 

One other solution I was trying using Field Parameters, where I added both Titles from the two tables, then altered the auto generated code and added an If statement based on my condition measure :

 

t4h4_0-1691982257844.png

The issue with this; the IF statement condition is always evaluating as True, even when [past] is False and so it's always returning the Title from Article table, never from Article7 ( [past] is working properly outside this ). I also tried replacing [past] with simple conditions like 1=1 or 1=2 just for testing, and it works.

 

That's [past] :

t4h4_2-1691996179626.png

 

[past] measure calculates the number of days between the earliest date in Calendar table and today, then compares it with a given value (400) and returns True or False.

 

I use this filter to filter out the Date in Calendar table and reduce the earliest date, but it looks like the field parameter DAX code is not considering this filter and only evalutes [past] the moment it was created.

t4h4_3-1691996463653.png

 

I tried to add the date filter in the [past] formula itself and it worked, but in my case I want this DATEVALUE to be dynamically changed using the filter above.

t4h4_4-1691997957149.png

 

 

Any help or suggestion on this ?

Feel free to propose another way to switch between the two columns as well.

 

Thank you.

 

 

2 REPLIES 2
Idrissshatila
Super User
Super User

hello @t4h4 ,

 

Try to use field parameters to switch between thses two columns 

https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Thanks for replying,

That's exactly what I was trying to do. However, I want the switching between the two columns to be automatically done based on my measure [past] mentioned above. I altered the default generated DAX code for the field parameters to achieve that... but that code is having issues.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.