Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I am trying to create identify with 1 and 2 the Max and Min date (1=Min and 2=Max).
Table2:
Month Order
April 2023 1
May 2023 2
Preferly in Power Query
or try this
let
YearNow = Date.Year( DateTime.LocalNow()),
MonthNow = Date.Month( DateTime.LocalNow()),
date1 =#date(YearNow,MonthNow-2,1) ,
date2 =#date(YearNow,MonthNow-1,1) ,
date3= #date(YearNow,MonthNow,1) ,
Source = #table(type table [Month=date, Order=Int64.Type],
{
{date1,1},{date2,2},{date3,3}
})
in
Source
Hi,
What if there are 12 rows (one for each month)? What should the result be?
in that case you can do this:
let
Source = List.Generate( ()=> #date(2023,1,1),
(x) => x<= #date(2023,12,1),
(x)=> Date.AddMonths(x,1)
),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), {"Month"}, null, ExtraValues.Error),
#"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Order", 1, 1, Int64.Type)
in
#"Added Index"
pls try this
let
Source = #table(type table [Month=date, Order=Int64.Type], {{#date(2023,4,1),1},{#date(2023,5,1),2}})
in
SourceIn this case month will be dynamic it won't always be those months
what do you mean dynamic? current month and previous month?
let
YearNow = Date.Year( DateTime.LocalNow()),
MonthNow = Date.Month( DateTime.LocalNow()),
startdate =#date(YearNow,MonthNow-1,1) ,
EndDate = #date(YearNow,MonthNow,1) ,
Source = #table(type table [Month=date, Order=Int64.Type],
{
{startdate,1},{EndDate,2}})
in
Source
This month JUNE 2023 it has APRIL 2023 and MAY 2023, next month
JULY 2023 it will have MAY 2023 and JUNE 2023, next month
AUGUST 2923 it will have JUNE 2023 and JULY 2023...
It will be always changing
pls try this
let
DateNow = List.Transform( List.Generate(()=> Date.AddMonths( Date.From( DateTime.LocalNow()),-2),
(x) => x <= Date.From( DateTime.LocalNow()),
(x) => Date.AddMonths(x,1)), (x) => Date.StartOfMonth(x)),
#"Converted to Table" = Table.FromList(DateNow, Splitter.SplitByNothing(), {"Month"}, null, ExtraValues.Error),
#"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Order", 1, 1, Int64.Type)
in
#"Added Index"
It didn't worked I added it in the advanced editor, maybe by doing step by step?
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 |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |