Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

If Condition

Hello All,

 

Iwas using IF condition to calculate based on condition.

 

While applying formula i could not able to select the comlumn name to filter the data. fpr example I've a table with column "type" , wish to filter with bundle under type

 

using below formula whihc is not allowing

 

=if(table[type]= "bundle"....... My query is, could not able to select the type column to define an expression.

 

Please help

 

REgards,

I

19 Replies

  • Anonymous are you adding a measure or column? if you are adding a column, it will work.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi All,

       

      I'm adding a measure, please help me with a solution for this.

       

       

      Need to add a measure becoz calculated column will not work for my data since i've other complications, hence should use Measure.

       

      1. need to count unique clients for each month, i used DIstinctCount(client).

      2. For Type = Bundle, it should take the count from the Count Column, for example, for Client A the clint count for May month is 50 and April 65.

      3. For all Regular Client count should Client Column by using DistinctFunction.

       

      i've created Distint count ( Disctinct Cout of column Client) as a single measure and Sum of Bundle clients (Sum(count)) as anotheer Measure, and trying to create a new measure by applying IF condition, as below 

       

      If(Table[Type]="Bundle",(distinctcountmeasure), (sumof Bundle measure))

       

      Please correct me and advise the solution accrordingly.

       

      REgards

      • parry2k's avatar
        parry2k
        Super User

        Anonymous if you want to add as measure, you need use aggregation for your type in calculation, something like this

         

        If(MAX(Table[Type])="Bundle",(distinctcountmeasure), (sumof Bundle measure))
  • v-xicai's avatar
    v-xicai
    Community Support

    Hi,

     

    You can create measure Count Clients to distinct count the [Clients], and create measure Filter1 to filter the table visual to display the [Type])="Bundle"  by putting the Filter1 in the Visual Level Filter of table visual ,setting Filter1 as "is not blank".

     

    Count Clients = CALCULATE(DISTINCTCOUNT(Table1[Clients]),FILTER(Table1,Table1[Type]=MAX(Table1[Type])&&Table1[Clients]=MAX(Table1[Clients])&&MONTH(Table1[Date])=MONTH(MAX(Table1[Date]))))

     

    Filter1= IF(MAX(Table1[Type])="Bundle",1,BLANK())

     

     

     

     

     

     

     

     

     

     

    Best Regards,

    Amy

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      it doesnt worked. Please help with other logic

       

      REgards,

       

       

      • v-xicai's avatar
        v-xicai
        Community Support

        Hi Anonymous ,

         

        Could you please show me the error information form my pbix file? 

         

        For the error as you said above :

        MAX function dint work, shows error as many aurguments passed for MAx function.

         

        To work around the issue ,you can check if missing brackets ")".

         

        Or could you please share your sample data or screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

         

        Best Regards,

        Amy