Forum Discussion
Calculate new column based on another column's text
Hi.
Really banging my head over this one; all I need is to have a new column called Hours based on a division of the Minutes Column below, but I only want it to calculate if Category A.
i.e. If Category is A below, then divide the Minutes column by 60 to get Hours (decimal). Otherwise leave blank.
| Category | Minutes | Hours |
| A | 200 | 3.3 |
| B | 90 | |
| C | 180 | |
| D | 150 | |
| E | 240 | |
| F | 210 | |
| G | 35 |
Once I have the results then I plan to create an average measure which I can do via a Table visual.
Thanks in advance.
Hi seankeatingpb , create a calculated column with this code (let's call it Hours and let's suppose your table in named CategoryMinutes)
IF (
CategoryMinutes[Category] = "A",
DIVIDE( CategoryMinutes[Minutes], 60 )
)This will automatically leave a blank when category is different than A
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
1 Reply
- FBergamaschi
Super User
Hi seankeatingpb , create a calculated column with this code (let's call it Hours and let's suppose your table in named CategoryMinutes)
IF (
CategoryMinutes[Category] = "A",
DIVIDE( CategoryMinutes[Minutes], 60 )
)This will automatically leave a blank when category is different than A
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI