Forum Discussion

HR3038511's avatar
HR3038511
Helper I
1 year ago
Solved

Calculated table based on selection

Hi,    I need to create a calculated table that shows all the Sales Agents for one period. The period needs be selected via a filter. Hence, when one period is selected the table should react and o...
  • Chewdata's avatar
    1 year ago

    Hey!

    As my fellow uses stated, calculated tables and -columns are generated at the refresh and therefore will not react in the manner that you want. 

    To get the results you want, create a seperated datetable. and connect it to your data.

    Datetabel = 
    ADDCOLUMNS (
    CALENDAR (DATE(2024,1,1), DATE(2025,12,31)),
    "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
    "Year", YEAR ( [Date] ),
    "Monthnumber", FORMAT ( [Date], "MM" ),
    "MonthShort", FORMAT ( [Date], "mmm" ),
    "MonthLong", FORMAT ( [Date], "mmmm" ),
    "YearMonthNo", FORMAT ( [Date], "YYYY/MM" ),
    "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
    )
    

    you can now use a slicer on the Year column of the date table to filter only years you want.

    No Date column in Data?
    If you don't have a date column in your data, you can also create a seperate table that contains the years and use that as a slicer.

    You can create a slicer table with both Power Query (preferred) and DAX

    Power Query:

    let
        Source = Table.FromList({2023, 2024, 2025}, Splitter.SplitByNothing(), {"Period"}, null, ExtraValues.Error),
        ChangeType = Table.TransformColumnTypes(Source,{{"Period", Int64.Type}})
    in
        ChangeType


    DAX Tabel:

    Period = SUMMARIZE(YOURDATA, YOURDATA[Period])


    Result:

     

    If this solution helped solve your problem, please consider giving kudoes and mark it as a solution, so other users with similar problems can find the answer more quickly!