Forum Discussion
Anonymous
4 years agoNot applicable
Power BI desktop
Hi,
Hope you all are doing well!
If am trying to create a column using 'if'. The condition is this if number of participants found in the table then it shows some value, otherwise 0. Somehow, I am not getting the desired ouput.
Table 1:
| Country | City | Participants |
| ABC | GHJ | Yes |
| DHH | KJL | No |
| ABC | DEF | Yes |
| BNM | JKL | Yes |
| ABC | DEF | Yes |
New Column = if (Table 1[Country]= "ABC" && Table 1[City] ="DEF",COUNT(Table1[Participants]),0)
The output of the above query should be '2'
Can anyone tell me what's wrong with this query.
Hi Anonymous
Try this code to add a new column:
Column = Var _A = filter(all('Table 1'),'Table 1'[Country]=EARLIER('Table 1'[Country])&&'Table 1'[City]=EARLIER('Table 1'[City])) Var _B = COUNTROWS(_A) return if(_b>1,_B,0)output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
1 Reply
- VahidDMSuper User
Hi Anonymous
Try this code to add a new column:
Column = Var _A = filter(all('Table 1'),'Table 1'[Country]=EARLIER('Table 1'[Country])&&'Table 1'[City]=EARLIER('Table 1'[City])) Var _B = COUNTROWS(_A) return if(_b>1,_B,0)output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/