Forum Discussion
Create Calculated Column with Conditions
Good morning, I hope you can help me what I want to do in Power Bi in this
If a worker has the number 15 twice (that is, the name is repeated), how can I make a column place the number 2?
If a worker has a value less than 15, give me the number 1
If a worker has 3 times 15, let me have the number 3
Note: All this calculation in a single column as I can do it through the DAX language
- Anonymous4 years ago
Hi Anonymous ,
I think you can try this code to create a calculated column.
Calculated Column with Conditions = VAR _COUNT_15 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] = 15 ) ) VAR _COUNT_Lessthan_15 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] < 15 ) ) RETURN IF ( _COUNT_Lessthan_15 = 1, 1, _COUNT_15 )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 Replies
- Ashish_MathurSuper User
Hi,
See if this calculated column formula works
Count = calculate(countrows(Data),filter(Data,Data[Nombres]=earlier(Data[Nombres])&&Data[LIQ]=earlier(Data[LIQ])))
Hope this helps.
- AnonymousNot applicable
Good morning, is that formula to create a calculated column or a measure? I want to create a calculated column with those conditions.- Ashish_MathurSuper User
Hi,
As mentioned in my earlier message, mine is a calculated column formula.
- AnonymousNot applicable
- AnonymousNot applicable
Hi Anonymous ,
I think you can try this code to create a calculated column.
Calculated Column with Conditions = VAR _COUNT_15 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] = 15 ) ) VAR _COUNT_Lessthan_15 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] < 15 ) ) RETURN IF ( _COUNT_Lessthan_15 = 1, 1, _COUNT_15 )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.