DAX Table Function logic expression

Team,
This is my very first Forum post and question through the Enterprise DNA website, so excited to be here and hope that you all can help me…

I am looking to create a table off of distinct values from a prior or existing table. Once I have the table created, then I wanted to create a logical statement from Switch or if statement that would read the distinct value and produce another in the same table.

Example

Cost Center Code Distinct = DISTINCT(SELECTCOLUMNS(‘FAC_FTE_Cost_Center’,“Cost Center Code”,[Cost Center Code],“Cost_Center_Name”,[Cost Center Name]
))

Now in that same Dax code I wanted to read my cost center code and lay our logic… Make sense?? Just so you all are aware, I am new to DAX, so if my question is a little elementary then please excuse me as I get brought up to speed.

1 Like

@JosephNeamon,

Welcome to the forum – great to have you here!

A couple of things that will help you get the best possible support on the forum:

  1. you will always get the most specific and quickest answer if you post your PBIX file – it is very difficult to evaluate DAX in a vacuum. Often times, what is initially thought to be a DAX problem is actually a data modeling issue. Also, by posting a PBIX it will give the people responding a chance to test the solution they provide you.

  2. a mockup of the result you want to see. Again, this helps the responders check whether their solution meets your requirement.

If your data contains confidential information, here’s a quick guide to masking sensitive information before posting on the forum.

Thanks.

– Brian

Hi @JosephNeamon, we’ve noticed that no response has been received from you since the 9th of March.

We are waiting for the masked demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.

Please help me on this as I don’t see that there was anyone that asked to see the model? Where and how am I missing this request?

Please note that this should not me listed as Solved I never received a response

Hi @JosephNeamon,

Can you clarify what do you mean by-- “produce another in the same table.” .

Also is it possible for you to share a sample pbix file for us to give specific answer to your query. Along with expected output screen sort if possible.

Thanks
Mukesh

Hi @JosephNeamon, I do see what @BrianJ message that he replied. The posting is not marked solved yet.
Keith

@JosephNeamon,

Yes, per my earlier message and @MK3010’s, I think we’re all having difficulty assessing what the desired outcome here is. I am certain that if you post a PBIX and the expected output you’re looking for that you will get a speedy and specific response.

Thanks.

  • Brian

Hi team,
Sorry about the oversight on that as I thought that @BrianJ was just showing best practices. With that said let me try a little more explanation… “I would share my PBIX file, but its filled with a ton of H.R. data and it would just take me to long to privatize my PBIX file”. Sorry in advance for that. With that said, here is more of an explanation for you all.

In my PBIX file I have a table in which is called FAC_FTE_Cost_Center in which I am pulling certain fields to create a look up table in my PBIX file. Rather than going out to excel and creating a If statement in another column that references the [Cost Center Code], my goal was to do that directly in the PBIX table. I was curious to know if I could just achieve that in the below code. I mean, I understand that I would need to have additional code, but I didn’t know if that existed in DAX? Meaning that if Cost Center Code=12345 than “Greg”, could I use switch in a table to do this?

Cost Center Code Distinct = DISTINCT(SELECTCOLUMNS(‘FAC_FTE_Cost_Center’,“Cost Center Code”,[Cost Center Code],“Cost_Center_Name”,[Cost Center Name]
))

Hi @JosephNeamon,

You can easily use conditions to create a calculated column but it’s always best to create table using Power Query.

Regarding your if condition with lookup table, you can use RELATED/RELATEDTABLE function to fetch the value from another table.

Thanks
Mukesh

Hi @JosephNeamon, did the response provided by the users and experts help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query. Thanks!