Power Bi DAX: Show data from 6 months past start date

强颜欢笑 提交于 2020-03-04 19:41:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!