Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi
I have two date column but in each one there is sometimes the value null.
I need months between [startdatum] and [einddatum].
I have :
= Table.AddColumn(Bron, "duur dossierbehandeling", each if [Einddatum]<>null
then Number.Round(Number.From(([Einddatum] -[Startdatum])/( 365.25 / 12 )),0)
else Number.Round(Number.From((DateTime.Date(DateTime.LocalNow()) -[Startdatum])/( 365.25 / 12)),0))
But I miss the function to replace the date in [start date] with the value in [End date] if no date has been entered.
I am just an beginner , I'm learning of trying and sometimes asking. And so you can see : dutch and my english is not perfect...Please help me.
Solved! Go to Solution.
Hi @Nelleke-NL, I'm not sure wether I understand your needs but try to check this and update with your needs.
IMPORTANT: For future requests, provide sample data as table so we can copy/paste. It is also important to provide expected result based on sample data!
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XYzBDcAwCAN34R0JTJo2mQVl/zUagqqWvpDvbMwIlWWwilYqhIuBCLMYCVh2lOU8qIdju2j/yUjk2aMvF6QxJJHP1ZrW/v70bnPXXzdv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Startdatum = _t, Einddatum = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Startdatum", type date}, {"Einddatum", type date}}, "nl-NL"),
Ad_EinddatumUpdated = Table.AddColumn(ChangedType, "Einddatum Updated", each if [Einddatum] <> null then [Einddatum] else Date.From(DateTime.LocalNow()), type date),
Ad_StartdatumUpdated = Table.AddColumn(Ad_EinddatumUpdated, "Startdatum Updated", each if [Startdatum] <> null then [Startdatum] else [Einddatum Updated], type text),
Ad_Months = Table.AddColumn(Ad_StartdatumUpdated, "Months", each
Duration.Days( ([Einddatum Updated] - [Startdatum Updated]) / (365.25 / 12) )
, Int64.Type)
in
Ad_Months
Hi @Nelleke-NL, I'm not sure wether I understand your needs but try to check this and update with your needs.
IMPORTANT: For future requests, provide sample data as table so we can copy/paste. It is also important to provide expected result based on sample data!
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XYzBDcAwCAN34R0JTJo2mQVl/zUagqqWvpDvbMwIlWWwilYqhIuBCLMYCVh2lOU8qIdju2j/yUjk2aMvF6QxJJHP1ZrW/v70bnPXXzdv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Startdatum = _t, Einddatum = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Startdatum", type date}, {"Einddatum", type date}}, "nl-NL"),
Ad_EinddatumUpdated = Table.AddColumn(ChangedType, "Einddatum Updated", each if [Einddatum] <> null then [Einddatum] else Date.From(DateTime.LocalNow()), type date),
Ad_StartdatumUpdated = Table.AddColumn(Ad_EinddatumUpdated, "Startdatum Updated", each if [Startdatum] <> null then [Startdatum] else [Einddatum Updated], type text),
Ad_Months = Table.AddColumn(Ad_StartdatumUpdated, "Months", each
Duration.Days( ([Einddatum Updated] - [Startdatum Updated]) / (365.25 / 12) )
, Int64.Type)
in
Ad_Months
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
9 | |
7 | |
6 |