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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
alawode
Helper I
Helper I

Calculated Column that matches current cloumn only

Hi Experts,

I have a Current  "Customer 1" column with customer names and i am trying to create a new calculated column "Customer 2" that will ONLY accept values that currently exist in Customer 1 and no other values. How do i write a calculation without having to include all the hundreds of names in the Current "customer 1" column in the expression?

Thanks in advance

1 ACCEPTED SOLUTION

@alawode Well, honestly, that makes no sense to me in terms of practical use. But, be that as it may, you would need an Index column or something that identifies "earlier" and "later" like a date field. Let's say you add an Index column to your table in Power Query Editor, then you could do this:

Customer 2 Column = 
  VAR __Index = [Index]
  VAR __Customer = [Customer 1]
  VAR __MinIndex = MINX(FILTER('Table',[Customer]=__Customer),[Index])
RETURN
  IF(__Index = __MinIndex,[Customer 1],BLANK())

Follow on LinkedIn
@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

@alawode Not really enough information to go on. You could create a table VAR using DISTINCT to include all of the current values in Customer 1 column and then use the IN operator to check if the calculation is included in that set. Beyond that, not enough information to be specific with regards to a solution. 

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


Follow on LinkedIn
@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, here's the Sample data attached. Im trying to make sure that "Customer 2" column only has the values in "customer 1" column at all times, and the values should not be duplicated  (should be distinct in "Column 2" even if it appears more than once  in "Column 1").

ThanksDistinct.PNG

@alawode I'm not quite following the use case for this, perhaps you just need to create a new table using the formula: DISTINCT('Table'[Column 1])


Follow on LinkedIn
@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_DecklerHi GReg sorry for th confusion, im simply try to create a column (not a whole table), from the old one (Customer 1), with only the unique values, and not the duplicates

@alawode Well, honestly, that makes no sense to me in terms of practical use. But, be that as it may, you would need an Index column or something that identifies "earlier" and "later" like a date field. Let's say you add an Index column to your table in Power Query Editor, then you could do this:

Customer 2 Column = 
  VAR __Index = [Index]
  VAR __Customer = [Customer 1]
  VAR __MinIndex = MINX(FILTER('Table',[Customer]=__Customer),[Index])
RETURN
  IF(__Index = __MinIndex,[Customer 1],BLANK())

Follow on LinkedIn
@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_DecklerThanks a lot, this works

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors