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.
Scenario:
Fetch the count of products in a given date range between the Start and End Date Ranges.
Tables Used:
Product | Start | End |
A | 1/1/2020 | 1/5/2020 |
B | 1/9/2020 | 1/12/2020 |
C | 1/4/2020 | 1/8/2020 |
D | 1/5/2020 | 1/15/2020 |
Deliveries in progress = IF(ISBLANK(COUNTROWS(RELATEDTABLE('ProdDateRange'))),0,COUNTROWS(RELATEDTABLE('ProdDateRange')))
Complete M Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLUN9Q3MjAyADNNIcxYnWglJ7CAJULO0Agh6QwWMUFIWiDkXJBNAmuEmRoLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, Start = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Start", type date}, {"End", type date}}),
#"Inserted Date Subtraction" = Table.AddColumn(#"Changed Type", "Subtraction", each Duration.Days([End] - [Start]), Int64.Type),
#"Renamed Columns" = Table.RenameColumns(#"Inserted Date Subtraction",{{"Subtraction", "DateDiff"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each List.Dates([Start], [DateDiff]+1, #duration(1,0,0,0))),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Custom", "DateRange"}})
in
#"Renamed Columns1"
9. To display the number of product in the selected date range, add slicer with the dates column from Date table and in a table visual add the fields “Dates” and “Deliveries in Progress”.
10. Now we can see the required data based on the slicer selection.
Author: Kirthi Korukonda
Reviewer: Mounika Narayana Reddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.