Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Need help in adding a calculated column

Hi I want to show the count of Exotic and Non Exotic Fruits and Vegetables. While I got the solution to count Exotic, I need help in counting the non exotic ones. I have an added table and there is ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

     

     

     

     

     

    Non Exotic Col = if('Table'[Type] in {"Fruit","Vegetable"} && 'Table'[Sub Category] <> "Exotic",1,0)

     

     

     

     

    NonEXoctic COunt = 
    VAR Fruits =
        COUNTX (
            FILTER (
                'Table',
                'Table'[Type]
                    IN {
                    "Fruit"
                }
                    && 'Table'[Sub Category] <> "Exotic"
            ),
            'Table'[Type]
        )
    VAR veg =
        COUNTX (
            FILTER (
                'Table',
                'Table'[Type]
                    IN {
                    "Vegetable"
                }
                    && 'Table'[Sub Category] <> "Exotic"
            ),
            'Table'[Type]
        )
    RETURN
        SWITCH (
            TRUE (),
            'Table'[Type] = "Fruit" && 'Table'[Sub Category] = "Non Exotic", Fruits,
            'Table'[Type] = "Vegetable" && 'Table'[Sub Category] = "Non Exotic", veg,
            BLANK ()
        )
    
    
    

     

     

     

    Regards,

    Harsh Nathani


    Appreciate with a Kudos!! (Click the Thumbs Up Button)

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