Hi Everyone
Im hoping someone can help me with this .
Note - I have some experience using excel and have just started out learning DAX
Scenario -
I have the following Tables -
Transaction data - with sales figures by region / product type / date etc
DateKey - Has dates including all possible dates in my transaction data and extra cloumns for financial year / calendar year etc
Now I have created a table with two cloumns (disconnected to anything else) that I would like to use as a slicer. the Values are "12 Months", "24 Months", "36 Months" & Overall . They have a corresponding PERIOD ID's of 1/2/3/4 on the same table.
The idea is to use this slicer to drive a a column chart showing Sales figures by month . ie. 12 month sales /24 month sales etc
Work Done so far - I created 4 extra calculated columns on my date table with the correspoding names to my slicer table i.e 12 months / 24 months /36 months/ Overall . Thier values are either 0 or 1 based on whether the date falls within the selected period for e.g = for the 12 month column I have IF(DateKey[Date]>=EOMONTH(MAX(DateKey[Date]),-12)+1,1,0)
What I would like to do is have one more calculated column lets call it ("Relative Date") on my date table that is dynamic based on what I select on my Slicer . If I select 12 Months then I get the corresponding value from the 12 month column , so if the date falls within the 12 months i get a 1 else I get a 0.
This way I could create a column chart with Sales and Month with where the visual filter = 1 , it would show all dates for the time period
I have tried the following formula by reading through the forums, But it always results in 0 regardless of selection
Relative Date = IF(HASONEVALUE(Periods[PERIOD ID]),SWITCH(FIRSTNONBLANK(Periods[PERIOD ID],Periods[PERIOD ID]),1,DateKey[12 Months],2,DateKey[24 Months],3,DateKey[36 Months],4,DateKey[Overall]),0)
Any help would be appreciated , Also feel free to tell me If Im completely off track and perhaps provide a simpler solution.
Regards
Kam