cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
venus
Frequent Visitor

Calculation to check if an entry is there for a particular category

Hi All,

 

I am looking for a calcualtion for the below scenario. Can you please help.

 

Data

Account_Id, Program

1234, Program 1

1234, Program 2

1432, Program 1

1534, Program 3

 

The result should be a calculation for each of the programs which will just show a yes or no for that particular account. 

 

Acct,  Program 1, Program 2, Program 3

1234, Yes, Yes, No

1432, Yes, No, No

1534, No, No, Yes

1555, No, No, No

 

Thanks,

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

A most straightforward solution is PQ,

let
    Source = SourceT,
    #"Added Index" = Table.AddIndexColumn(Source,"Index",1,1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Program]), "Program", "Index", each if List.Count(_)>0 then "Yes" else "No")
in
    #"Pivoted Column"

CNENFRNL_0-1653167578639.png

 

DAX measure can do the trick, but an extra dimension is necessary,

CNENFRNL_1-1653167727287.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

A most straightforward solution is PQ,

let
    Source = SourceT,
    #"Added Index" = Table.AddIndexColumn(Source,"Index",1,1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Program]), "Program", "Index", each if List.Count(_)>0 then "Yes" else "No")
in
    #"Pivoted Column"

CNENFRNL_0-1653167578639.png

 

DAX measure can do the trick, but an extra dimension is necessary,

CNENFRNL_1-1653167727287.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

I used the pivot table approach for my issue. Thanks !!

 

tamerj1
Super User
Super User

Hi @venus 

New matrix, place the id on rows and program on columns. Then place this measure in the values

IF ( ISBLANK ( COUNTROWS ( TableName ) ), "False", "True" )

CNENFRNL
Community Champion
Community Champion

By your means, you'll get "True" cells but not even a single "False" due to auto-exist mechanism under the hood.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors