Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi everyone,
I have tried a lot of previous solutions I have found to this issue but I'm not being able to solve the IF problem
1. Recode birth year into age by 2020 - age :
Age = IF(BYear = Blank(), #Null or blank?#, (2020 - BYear))
The year is in number format, not date.
2.Recode this result into an interval:
IF(Age < 35, "<35 Years", IF(Age < 45, "Between 35 and 45 years",">45"))
(Both cases there something wrong with IF even if variables format are ok )
Thanks for your help
Solved! Go to Solution.
Hi @Pablo_Quintana ,
You can make this on the query editor or adding a column in DAX:
Power Query:groupin
if [BYear] = null then null else (2020- [BYear])
DAX:
Column = IF('Table'[BYear] = BLANK();BLANK();2020 - 'Table'[BYear])
Then you can make a group or new column wiht the following syntax:
Column 2 = SWITCH(TRUE();'Table'[Age] = BLANK();BLANK(); 'Table'[Age] < 35; "<35 Years"; 'Table'[Age] < 45 && 'Table'[Age] > 35; "Between 35 and 45 years";">45")
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Pablo_Quintana ,
You can make this on the query editor or adding a column in DAX:
Power Query:groupin
if [BYear] = null then null else (2020- [BYear])
DAX:
Column = IF('Table'[BYear] = BLANK();BLANK();2020 - 'Table'[BYear])
Then you can make a group or new column wiht the following syntax:
Column 2 = SWITCH(TRUE();'Table'[Age] = BLANK();BLANK(); 'Table'[Age] < 35; "<35 Years"; 'Table'[Age] < 45 && 'Table'[Age] > 35; "Between 35 and 45 years";">45")
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsSry for being so late, I haven't been working on this the last week, well I have tried both solutions but there's something wrong, even if the formula it's working, Power Bi warn me about an error in the IF or Switch clause, but the column has the values, which is extremely weird.
Hi @Pablo_Quintana ,
What is the error you are getting can you share a print screen?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@Pablo_Quintana , Try like
Age = IF( isblank([BYear]) , blank(), (2020 - [BYear]))
Switch ( True(),
[Age] < 35, "<35 Years",
[Age] < 45, "Between 35 and 45 years"
,">45")
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 70 | |
| 39 | |
| 35 | |
| 23 |