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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Shaji
Helper I
Helper I

DAX Query

Hi,

For instance I have a table like this:

CustomerCust IDTypeSales
A11Platinum100
A11Gold20
A11 300
B12Silver200
C13Gold100
C13Silver400
D14Platinum600

 

Now I need to show in a card or some box the type of Customers:

 

Eg: If i select a customer name using the select box then ideally my result should be:

 

CustomerPlatinumGoldSilver
AYesYesNo

 

I belive we should use DAX query to get the result. Please advice

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Shaji 

 

You can create three columns.

 

Platinum = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Platinum"),data[customer])
Return if (a>=1, "Yes","No")
Gold = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Gold"),data[customer])
Return if (a>=1, "Yes","No")
Silver = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Silver"),data[customer])
Return if (a>=1, "Yes","No")

1.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@Shaji 

 

You can create three columns.

 

Platinum = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Platinum"),data[customer])
Return if (a>=1, "Yes","No")
Gold = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Gold"),data[customer])
Return if (a>=1, "Yes","No")
Silver = 
VAR a=countx(FILTER('data',data[customer]=EARLIER(data[customer])&&data[TYPE]="Silver"),data[customer])
Return if (a>=1, "Yes","No")

1.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Shaji ,

Try like

Type measure = coalesce(max(Table[Type]),"No")

@amitchandak 

 

 

The result comes as:

Customer Platinum Gold Silver
A              Platinum Gold  No

 

instead of 

 

Customer Platinum Gold Silver
A              Yes           Yes   No

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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