Forum Discussion
creating measure using dax
- 3 years ago
Since you already have a date table then no need for a Years table. Sorry for that but I did not have all the information about your data model.
Two relationshops have to be created. One "Active" between DateTable[Date] and Query[Basic fin.] and other "Inactive" between DateTable[Date] and Query[Out of Warranty]
The measure would be
Remaining Quanitiies of Product Still in Warrenty = CALCULATE ( SUM ( 'Query'[Del. qty] ), 'DateTable'[Year] >= MAX ( 'DateTable'[Year] ), USERELATIONSHIP ( 'Query'[Out of Warranty], 'DateTable'[Date] ) )
Hi osama_ayoub
First of all the existing [Year] column represents the year of the [Basic fin.] date. You need to create a new [Out of Warranty Year] column which simply YEAR ( 'Table'[Out of Warranty] ).
In order to be able to see KPI's that are related to any of the year columns at the same time in the same visual, you need also to have a dimension 'Years' table and is simply a single column table that is linked with an active relationship with 'Table'[Year] and a non-active relationship with 'Table'[Out of Warranty Year]. Then you can place 'Years'[Year] column in a visual along with your measures.
Remaining Quanitiies of Product Still in Warrenty =
CALCULATE (
SUM ( 'Table'[Del. qty] ),
'Years'[Year] >= MAX ( 'Years'[Year] ),
USERELATIONSHIP ( 'Table'[Out of Warranty Year], 'Years'[Year] )
)- osama_ayoub3 years ago
Helper III
I created a table (has all distinct years in query table) as a link between query table(which have my sales data) and calender table ,but I got this error
- osama_ayoub2 years ago
Helper III
Hi Tamer,
Thanks for your help
I have Create 2 relationship
one active relation between column(Date in Date Table) and (Date in my fact Table (Report)
another relation (inactive) between (Date in Date Table) and (Out of Warrenty in my fact Table (Report))
and have created measure like in the attached screenshot , and it seems it work fine but I should have a inreasing Trend in the start of seeling the products and then it shoud decline with years because in the first years of seeling the products it should be increasing quantity of products still in warrenty ?Regaeds
- tamerj12 years ago
Community Champion
It should be <= not >=
that was a mistake from my side.- osama_ayoub2 years ago
Helper III
I reversed the sign but now It corrected the firs part but the second part (the curve should be go down with every unit outing from warrenty )
Regards