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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
alawode
Helper I
Helper I

Calculating a new column by grouping the values

Hi Experts,

I have the following Products Column (attached), and i am trying to create a new calculated column that will have car names as "Cars", the Blank values as "Blank" and everthing else shold be called "BIKES".  so basically just 3 unique vales in the new column .Products.PNGPlease whats the best expression to achive this?

Thanks in advance

1 ACCEPTED SOLUTION

I am trying to use the calculatd colmn as a filter so the "Binning" solution didnt work. I ended up using the Switch Function. Thanks

View solution in original post

4 REPLIES 4
Jakinta
Solution Sage
Solution Sage

If your car models are always upper cased, and bikes are in proper casing then you can use this trick:

= Table.AddColumn( YourProiorStepName, "Custom", each if [Products] = Text.Upper([Products]) and Text.Upper([Products])<>"BLANK" 
then "Cars" else if Text.Upper([Products])= "BLANK" then "Blank" else "BIKES")

Otherwise you would have to create some Table(s) or List(s) with cars and bikes models then perform some merging or testing on containment. There are plenty of threads on that topic on forum...

Im basically trying to create a case statement that will create the calcualted column, is there no way to do this in Power BI?

Yes.  There is a simple way to do it w/ no code, using a Groups column.

Use grouping and binning in Power BI Desktop - Power BI | Microsoft Docs

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


I am trying to use the calculatd colmn as a filter so the "Binning" solution didnt work. I ended up using the Switch Function. Thanks

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors