Files
kucherenko__jscpd/fixtures/powerquery/file2.pq
apk 64e471e2b0 test: raise coverage to 96%+ on @jscpd/finder and 98%+ on apps/jscpd
Adds 92 new tests (178 → 270 total) with zero source-file modifications:

- packages/finder: 13 new test files covering all reporters, subscribers,
  validators, hooks, utils, options, cloneFound, getFilesToDetect, and
  InFilesDetector; shared buildClone() factory helper
- apps/jscpd: 3 new test files (options-unit, print, store) plus extensions
  to formats, modes, and options integration tests
- vitest.config.ts added to both packages to restrict coverage.include
  to src/** only, eliminating bin/ and prism.js noise
- Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization
  edge cases) uncovered by the new format fixture suite
- Adds fixture files for 40+ language formats to support formats.test.ts
2026-05-09 15:00:38 +02:00

58 lines
1.6 KiB
PowerQuery

// Power Query M - ETL for sales data
let
// Load raw sales data from CSV
Source = Csv.Document(
File.Contents("C:\Data\sales.csv"),
[Delimiter=",", Columns=8, Encoding=65001, QuoteStyle=QuoteStyle.None]
),
// Promote first row to headers
PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
// Change column types
TypedTable = Table.TransformColumnTypes(PromotedHeaders, {
{"OrderId", type text},
{"OrderDate", type date},
{"CustomerId", type text},
{"ProductId", type text},
{"Quantity", Int64.Type},
{"UnitPrice", type number},
{"Discount", type number},
{"Region", type text}
}),
// Add calculated columns
WithRevenue = Table.AddColumn(
TypedTable, "Revenue",
each [Quantity] * [UnitPrice] * (1 - [Discount]),
type number
),
WithYear = Table.AddColumn(
WithRevenue, "OrderYear",
each Date.Year([OrderDate]),
Int64.Type
),
WithQuarter = Table.AddColumn(
WithYear, "OrderQuarter",
each "Q" & Text.From(Date.QuarterOfYear([OrderDate])),
type text
),
// Group by region and year, sum revenue
Grouped = Table.Group(
WithQuarter,
{"Region", "OrderYear"},
{{"TotalRevenue", each List.Sum([Revenue]), type number},
{"OrderCount", each Table.RowCount(_), Int64.Type}}
),
// Sort by region then year
SortedGroups = Table.Sort(
Grouped,
{{"Region", Order.Ascending}, {"OrderYear", Order.Ascending}}
)
in
SortedGroups