Forum Discussion

harib's avatar
harib
Post Patron
6 years ago

Conditions for Columns

Hi All,

 

I have senario like below table  . 

 

Main Table 

SNO      MG      MU      MP     LG      LU       Percentage1        Percentage2

1            XX       AA       BB      CC      DD       80%                   75%

2            XX       AA       BB      CC      DD       75%                   75%

 

Bridge Table 

Sno     Group      Attributes

1          MG           XX

2          MG           XX

3          MU           AA

4          MU           AA

5          MP           BB

6          MP           BB

7          LG            CC

8          LG            CC

9          LU            DD

10        LU            DD

 

Based on the SNO created relationship. So far it's fine.  Now Group column from the bridge table used in the slicer. In the slicer it's coming like 

MG

MU

MP

LG

LU

 

In Table visual i have used GROUP and  Attributes columns from the Bridge table. Table will be look like below

 

Group      Attributes      Calculated values 

MG           XX

MG           XX

MU           AA

MU           AA

MP           BB

MP           BB

LG            CC

LG            CC

LU            DD

LU            DD

 

Now If i select MG or MP or MU from slicer it should display Percentage 1 values

If i select LG or LU  from slicer it should display Percentage 2 values in the calculated column as i mentioned above table. 

 

I hope it's clear. Is it possible in Power BI, If yes colud u plese let me know.

 

Thanks 

8 Replies

  • harib ,

     

    Create calculated column like below:

    Column 1  = if(OR(HASONEVALUE(Sheet7[MG]),HASONEVALUE(Sheet7[MU])),"Yes")
    Column2 = if(OR(HASONEVALUE(Sheet7[LG]),HASONEVALUE(Sheet7[LU])),"No")
     
    Please give Thumbs up for support and accept this as a solution if it helps you!
    • harib's avatar
      harib
      Post Patron

      Tahreem24 

      If i would like to add one more column (MP), when i add MP Column, syntax is showing wrong. Can u pls let me know.

       

      Thanks

  • Anonymous's avatar
    Anonymous
    Not applicable

    "I woluld like to give condition like if it is MG, MU then in column1 it should come Yes , if it is LG, LU then in column 2 it should come No.  "

     

    Can you clarify?

    If MG=MU?

     

    I guess that you're showing an actual table (and not a visual), so you can do that either in PowerQuery M or in DAX. Both solutions are equivalent.

    I would do 

    Column1=IF(Table[MG]=Table[MU];"Yes") 

     

    but you first need to clarify the question

    • harib's avatar
      harib
      Post Patron

      Updated the Requirment. Can u please give me the solution.

  • harib ,

     

    Try the below calculated column:

     

    Column2 = if(Sheet7[Group] in {"MG","MU","MP"},"1%","2%")
    • Tahreem24's avatar
      Tahreem24
      Super User

      Or try this to get percentage value:

       

      Column2 = if(Sheet7[Group] in {"MG","MU","MP"},0.01,0.02)
       
      Don't for get to hit Thumbs up for support and accept this as a solution if it helps you!
      • harib's avatar
        harib
        Post Patron

        Tahreem24 

         

        I have used Related function to call the percentage values from the main table. But not getting percentage for LG,LU values. I dont want to give manuval values.