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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
dbrandone
Helper III
Helper III

Power Query Issue - Add Column only showing null values

Hi everyone,

 

I have a table that I am trying to add a column in power query. I have a similar table that the code (similar code) worked just fine, but for some reason this column is only showing null values which is from the "else" statement. I made sure that all of my data types were correct and that the values in the if or else if statements match (they are only one letter). Thinking that maybe another set of eyes would help. I am trying to make all ages whether they were inputted at the datasource (measured) as Y(Year), M(Month), W(Week), or D(Days), to be relative to one another. This has me stumped. Below is the power query formula I wrote and a picture of the columns that I am referencing. 

 

Table.AddColumn(#"Changed Type2", "Age(Yrs)", each if [Age Measurement] = "Y" then [#"Age (Don't Use)"] else if [Age Measurement] = "M" then [#"Age (Don't Use)"]/12 else if [Age Measurement] = "W" then [#"Age (Don't Use)"]/52 else if [Age Measurement] = "D" then [#"Age (Don't Use)"]/365 else 0)

 

dbrandone_0-1658158240088.png

The Age(Yrs) column that I am trying to create should pull over the value from the "Age (Don't Use)" column if the Age Measurement is Y, Divide the Age(Don't Use) column by 12 if the Age Measurement is M, and so on for W(Weeks) and D(Days).

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@dbrandone Maybe try trimming and cleaning your Age Measurement column?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@dbrandone Maybe try trimming and cleaning your Age Measurement column?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

 

Thanks, trimming worked. I tried cleaning first, and it did not but trimming did. Can you explain what that did? None of the values seem to have changed? Is this a background data change?

@dbrandone Trimming gets rid of white space or essentially blanks/non-printing characters.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.