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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

how to mark every "LAST DATE" in every month using "POWER QUERY"

how to mark every "LAST DATE" in every month using "POWER QUERY"
why "POWER QUERY" because after that it will be "filtered" and "grouped by"

 

example
Date            | Flag

-------------| ----

30/06/2022 | 0
31/06/2022 | 1
01/07/2022 | 0
02/07/2022 | 0
03/07/2022 | 0
...
10/07/2022 | 1 --> today

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

You can create add a custom column as below in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VdGxDYAwEEPRXVIjJXZISGZB7L8GokH+5a/uyXffZVRVN7s8xxfO6BlnxsiYGVfGytgZaigYBISgEBiCQ4AIEoEiWAyLuQcshsWwGBbDYlgMi2HpsPSwzIpwRs84M0bGzLgyVsbG0YYiCAhB8T/qeQE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Flag", each if [Date] = Date.EndOfMonth([Date]) or [Date] = Date.From(DateTime.LocalNow()) then 1 else 0)
in
    #"Added Custom"

yingyinr_0-1655196338953.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

You can create add a custom column as below in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VdGxDYAwEEPRXVIjJXZISGZB7L8GokH+5a/uyXffZVRVN7s8xxfO6BlnxsiYGVfGytgZaigYBISgEBiCQ4AIEoEiWAyLuQcshsWwGBbDYlgMi2HpsPSwzIpwRs84M0bGzLgyVsbG0YYiCAhB8T/qeQE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Flag", each if [Date] = Date.EndOfMonth([Date]) or [Date] = Date.From(DateTime.LocalNow()) then 1 else 0)
in
    #"Added Custom"

yingyinr_0-1655196338953.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
johnt75
Super User
Super User

You could compare the date field with Date.EndOfMonth(). You may need to play about with converting your current date field to datetime but you should be able to do that in the comparison code.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.