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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
afrutos
Resolver I
Resolver I

Conditional

 

Hello everyone, I have a question that I can't solve.
In this table I have a column with IdAuthor, and another that is Author Category.
I need to calculate something like this:
If the IdAuthor is Director, Writer and Screenwriter, I need to put "Director and Screenwriter".
If the IdAuthor is Director then Director
However when I apply my formula with SWITCH clause it doesn't get it for when the IdAuthor is Director, Writer and Writer at the same time.
This is my formula

Can you help me? Thanks

afrutos_1-1640188597923.png

 

 

afrutos_0-1640188517933.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @afrutos ,

You can create a calculated column as below, please find the details in the attachment.

Category = 
VAR _category =
    CONCATENATEX (
        FILTER (
            ALL ( 'Authors' ),
            'Authors'[IdAuthor] = EARLIER ( 'Authors'[IdAuthor] )
        ),
        [CategoryAuthor],
        ",",
        'Authors'[CategoryAuthor]
    )
RETURN 
    IF (
        _category = "Director,Screenwriter,Writer ",
        "Director and Screenwriter",
        'Authors'[CategoryAuthor]
    )

yingyinr_0-1640592339077.png

Best Regards

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @afrutos ,

You can create a calculated column as below, please find the details in the attachment.

Category = 
VAR _category =
    CONCATENATEX (
        FILTER (
            ALL ( 'Authors' ),
            'Authors'[IdAuthor] = EARLIER ( 'Authors'[IdAuthor] )
        ),
        [CategoryAuthor],
        ",",
        'Authors'[CategoryAuthor]
    )
RETURN 
    IF (
        _category = "Director,Screenwriter,Writer ",
        "Director and Screenwriter",
        'Authors'[CategoryAuthor]
    )

yingyinr_0-1640592339077.png

Best Regards

Hi, thank you how did you create the colum "column"?
I need to do this step before

Anonymous
Not applicable

Hi @afrutos ,

Please right-click or select the ellipsis ... next to the table Author in the Fields pane, and select New column from the menu just as below screenshot. You can find more details in the following official documentation.

Tutorial: Create calculated columns in Power BI Desktop

yingyinr_0-1640942558270.png

Best Regards

Yes I know how to create a new Column, but my question is what did you do in that Calculated Column.
I mean, you showed me the column Category, 
Could you please showed me the Column column?

Anonymous
Not applicable

Hi @afrutos ,

You can just ignore that calculated column. I created that calculated column to show the unique category that each author belongs to, and then each category is concatenate with a ",".

Column = 
CONCATENATEX (
    FILTER ( 'Authors', 'Authors'[IdAuthor] = EARLIER ( 'Authors'[IdAuthor] ) ),
    'Authors'[CategoryAuthor],
    ",",
    'Authors'[CategoryAuthor]
)

yingyinr_0-1640943930579.png

Best Regards

ryan_mayu
Super User
Super User

@afrutos 

the Dax you highlighted does not work. You can try this

Column = 
VAR _d=maxx(FILTER('Table','Table'[IdAutor]=EARLIER('Table'[IdAutor])&&'Table'[CategoriaAtor]="Director"),'Table'[CategoriaAtor])
VAR _g=maxx(FILTER('Table','Table'[IdAutor]=EARLIER('Table'[IdAutor])&&'Table'[CategoriaAtor]="Guionista"),'Table'[CategoriaAtor])
VAR _a=maxx(FILTER('Table','Table'[IdAutor]=EARLIER('Table'[IdAutor])&&'Table'[CategoriaAtor]="Argumentista"),'Table'[CategoriaAtor])
return if(_a<>""&&_g<>""&&_d<>"","Director and Screenwriter")

1.PNG





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

Proud to be a Super User!




amitchandak
Super User
Super User

@afrutos , a new column like

 

New column =
var _1 = countx(filter(Table, [IdAuthor] =earlier([IdAuthor]) && [CategoryAuthor] in {"Director","Writer","Screenwriter"} ) ,[IdAuthor])+0
var _2 = countx(filter(Table, [IdAuthor] =earlier([IdAuthor]) && [CategoryAuthor] in {"Director"} ) ,[IdAuthor])+0
return
switch(true(),
_1=3, "Director and Screenwriter",
_2 =1 , "Director",
[CategoryAuthor]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, i'm sorry but it's still not working
Because for exaple for the first one I should have "Director and Screenwriter"

afrutos_1-1640190554316.png

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors