问题
i have been having trouble trying to figure out how to show my data past a date that is 6 months past the start date.
I need to show the values that are after the 6 months past the start date.
Each date is different for each person
i have the formula as a calculated column for the 6 months: +6m = DATEADD('Employee List'[Emp. Dates].[Date], +6, MONTH)
A measure will not work because i cannot apply it to my table as it comes up with an error.
How do i get it to work? Should i scrap the +6m column for a new formula?
回答1:
Basic measure:
Total Sales = SUM(Sales[Total Sales])
As long as you do not provide sample data, it is just guessing what you want. It might be it:
YourMeasure =
CALCULATE (
[Total Sales],
DATEADD (
'Employee List'[Emp. Dates].[Date] -- it is better to use here 'Calendar'[Date]
-6,
MONTH
)
)
update
This will give you a good start.
Sample data:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1MAQiJR0lQ6VYHZiQEaaQMaaQCaaQKaaQGaaQOaaQBaaQJYaQoQGmEKbrDdFdb4jpR0NkP8YCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Amount = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Amount", Int64.Type}})
in
#"Changed Type"
Measure =
var MinDate = CALCULATE( MIN(T[Date]), REMOVEFILTERS(T[Date]) )
var SixMonthAfter = CALCULATE( DATEADD( T[Date], 6 , MONTH ), T[Date] = MinDate )
return
CALCULATE( SUM( T[Amount] ), FILTER( T, T[Date] > SixMonthAfter ) )
来源:https://stackoverflow.com/questions/59929473/power-bi-dax-show-data-from-6-months-past-start-date