Forum Discussion
Dax function
Hi Anonymous,
I think for your use case, it would be simpler to compute for the daily salary instead of dividing the salary by 4 to get the quarterly rate as not all start dates fall in the first day of the month and not all months have the same number of days. This can easily done using Power Query. This approach will make your DAX calculations simpler.
Here's a sample M Script that demostrates what I just mentioned.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckktU9JR8krMUzDUUTAyMDIC8gwNDHQMDAyUYnWilYITc1KLgWK+iUUKxggVRpgqvEpzKnEYEuALFPBPLlEwNEDImyDkoY4oRXMEWDoWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Stream = _t, #"Start Date" = _t, #"Annual Salary" = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
#"Changed Type" = Table.TransformColumnTypes(#"Added Index",{{"Stream", type text}, {"Start Date", type date}, {"Annual Salary", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Days to Next Year", each let
start = [Start Date],
end = #date(Date.Year(start) + 1, Date.Month(start), Date.Day(start))
in
Number.From( end - start) + 1, Int64.Type),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Dates", each List.Dates([Start Date], [Days to Next Year], #duration(1, 0, 0, 0) )),
#"Inserted Division" = Table.AddColumn(#"Added Custom1", "Daily Salary to Year End", each [Annual Salary] / [Days to Next Year], type number),
#"Expanded Dates" = Table.ExpandListColumn(#"Inserted Division", "Dates"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}})
in
#"Changed Type1"
And here's how it can look in the report view.
Thank you danextian
What DAX function did you use to get that report view?
Also are you able to group the report by stream and sum up their salaries?
Thanks again
- danextian4 years agoSuper User
Hi Anonymous ,
I didn't create any calculated column or measure. Here's a sample pbix for your reference -https://drive.google.com/file/d/1VoQ0wf67_r_Hat1vKxsnuPfIEBR5AoZU/view?usp=sharing