Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I would like to count the number of days an invoice is paid in full. So in the same column the difference between the min and max date per invoice number.
As a table I use the general ledger mutation table for this. So I have multiple rows per invoice. This looks like this:
Invoice number | date |
101 | 1-1-2019 |
101 | 1-2-2019 |
101 | 2-2-2019 |
101 | 3-2-2019 |
101 | 4-2-2019 |
101 | 5-2-2019 |
101 | 6-2-2019 |
101 | 7-2-2019 |
102 | 1-1-2019 |
102 | 2-1-2019 |
102 | 3-1-2019 |
102 | 4-1-2019 |
Solved! Go to Solution.
@KGPBI , a most straightforward way is to calculate the duration in Power Query,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc7BDQAQEATAXu5NYtchahH9tyHxIOx3XjOGIcGCISIyodsMl/gTlbKSKxWlqtReor64E0JZyQ/NBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Invoice number" = _t, date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Invoice number", Int64.Type}, {"date", type date}}, "en-GB"),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Invoice number"}, {{"Diff", each Duration.Days(List.Max([date])-List.Min([date]))+1}})
in
#"Grouped Rows"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@KGPBI , a most straightforward way is to calculate the duration in Power Query,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc7BDQAQEATAXu5NYtchahH9tyHxIOx3XjOGIcGCISIyodsMl/gTlbKSKxWlqtReor64E0JZyQ/NBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Invoice number" = _t, date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Invoice number", Int64.Type}, {"date", type date}}, "en-GB"),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Invoice number"}, {{"Diff", each Duration.Days(List.Max([date])-List.Min([date]))+1}})
in
#"Grouped Rows"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
6 |