Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ArashZ
Helper I
Helper I

calculated column

Hi,

 

I have a table like the below:

There are some companies on the table and each one sells different products. As can be seen, in the table, if the product code is glasses or shipping or additional item, the plan frequency column is monthly; otherwise is yearly. I want to create a new plan frequency modified column in a way that if a car or pen or pencil exists for that company, all the plan frequencies for that company change to yearly. The new desired common is also shown.

 

Company NamePlan frequencyProductcode
AMonthlyglasses
AMonthlyshipping
AYearlycar
AYearlypen
BMonthlyglasses
BYearlypen
BYearlypencil
BYearlybottle
CMonthlyglasses
CMonthlyshipping
CYearlycar
CYearlypen
CMonthlyadditional item

 

ArashZ_0-1664262517606.png

 

7 REPLIES 7
wdx223_Daniel
Super User
Super User

CalculatedColumn=VAR _c=Data[Company Name] RETURN IF(COUNTROWS(FILTER(Data,Data[Company Name]=_c&&Data[Productcode] IN {"car","pen","pencil"})),"Yearly",Data[Plan frequency])

@wdx223_Daniel 

 

Thank you, but the solution doesn't work. The table still shows some monthly values.

Hi, @ArashZ 

If @wdx223_Daniel 's formula doesn't work, can you show relevant screenshots to further investigate what's causing the error?

Also, check if the bias in the results is caused by errors in the data itself.

Best Regards,
Community Support Team _ Eason

AnthonyJoseph
Resolver III
Resolver III

Hi @ArashZ 

I think this is what you are looking for...

Plan Frequency Modified = 
var _isinlist = CALCULATE(COUNT('Table'[Productcode]),CONTAINSROW({"car","pen","pencil"},'Table'[Productcode]),FILTER(ALLEXCEPT('Table','Table'[Company Name]),'Table'[Company Name] = EARLIER('Table'[Company Name])))
return
if(_isinlist >=1,"Yearly", "Monthly")

 

AnthonyJoseph_0-1664264836681.png

Hope this helps!

 

Thanks, 

AnthonyJoseph

@AnthonyJoseph 

 

Thanks, but I received this error.

A single value for the column company name in the table cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation to get a single result.

Hi @ArashZ 
Would you be able to share the DAX that you tried so that I can see if there are any syntatical errors.
Thanks,
AnthonyJoseph

Hi @ArashZ 

 

Please can you provide data anonymising/removing the sensitive information.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.