Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello All, I have got myself turned all upside down and sideways. I am trying to figure out how to accomplish the following mission and I keep getting hung up because I can't find videos that are specific to my issue or am not merging them together properly. My data shows below:
Issues
Here is what I want to do.
In the DL Exp column, I want to be able to:
Now, I am not adverse to creating a second column in the Power Query, but when all of this comes together in the Power BI report, I want there to be one column that has one of these things:
As you can see... I'm all turned upside down/sideways... and hoping someone can help me think through this a little bit. I have been working on this for ~90 minutes now... and am just confused about a path forward.
Solved! Go to Solution.
I think you are confusing things by bringing in text conversions in other columns initially. It is generally much simpler to work with dates as the date data type, then as text strings which have to be converted back and forth.
Starting with the three columns that you are obtaining from your data source, just add a Custom column that performs the logic for that column:
eg
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcm7DcAgDEXRXVwj+Y9NnTEQRVbI/kUoEEGRnl5xT+/AQZquUOC6n/lMyIZC0mCUyaapsTVQ5oh9YRX50JH9wAxlr1tXVK3ZfjHImeyI4wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [account_id = _t, #"DL Type" = _t, #"Expir Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"account_id", Int64.Type}, {"DL Type", type text}, {"Expir Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DL Exp",
each if [Expir Date] = null
then "No DL Expiration Date on File"
else if [Expir Date] < Date.From(DateTime.LocalNow())
then "DL Expired"
else [Expir Date])
in
#"Added Custom"
or, if the date in the "DL Exp" column for some reason related to data presentation **must** be as text in that format, then:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcm7DcAgDEXRXVwj+Y9NnTEQRVbI/kUoEEGRnl5xT+/AQZquUOC6n/lMyIZC0mCUyaapsTVQ5oh9YRX50JH9wAxlr1tXVK3ZfjHImeyI4wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [account_id = _t, #"DL Type" = _t, #"Expir Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"account_id", Int64.Type}, {"DL Type", type text}, {"Expir Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DL Exp",
each if [Expir Date] = null
then "No DL Expiration Date on File"
else if [Expir Date] < Date.From(DateTime.LocalNow())
then "DL Expired"
else Date.ToText([Expir Date],"yyyy-MM-dd"), type text)
in
#"Added Custom"
I think you are confusing things by bringing in text conversions in other columns initially. It is generally much simpler to work with dates as the date data type, then as text strings which have to be converted back and forth.
Starting with the three columns that you are obtaining from your data source, just add a Custom column that performs the logic for that column:
eg
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcm7DcAgDEXRXVwj+Y9NnTEQRVbI/kUoEEGRnl5xT+/AQZquUOC6n/lMyIZC0mCUyaapsTVQ5oh9YRX50JH9wAxlr1tXVK3ZfjHImeyI4wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [account_id = _t, #"DL Type" = _t, #"Expir Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"account_id", Int64.Type}, {"DL Type", type text}, {"Expir Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DL Exp",
each if [Expir Date] = null
then "No DL Expiration Date on File"
else if [Expir Date] < Date.From(DateTime.LocalNow())
then "DL Expired"
else [Expir Date])
in
#"Added Custom"
or, if the date in the "DL Exp" column for some reason related to data presentation **must** be as text in that format, then:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcm7DcAgDEXRXVwj+Y9NnTEQRVbI/kUoEEGRnl5xT+/AQZquUOC6n/lMyIZC0mCUyaapsTVQ5oh9YRX50JH9wAxlr1tXVK3ZfjHImeyI4wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [account_id = _t, #"DL Type" = _t, #"Expir Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"account_id", Int64.Type}, {"DL Type", type text}, {"Expir Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DL Exp",
each if [Expir Date] = null
then "No DL Expiration Date on File"
else if [Expir Date] < Date.From(DateTime.LocalNow())
then "DL Expired"
else Date.ToText([Expir Date],"yyyy-MM-dd"), type text)
in
#"Added Custom"
Thank you -- this will give me ideas for the future too.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.