Forum Discussion
Anonymous
3 years agoNot applicable
Transform table to another format
Hi, I would like to transform data to another format so I can use it as an fact. It is data about tracking car rides. From a source I receive the following data: CarNr Date StartDate...
- Anonymous3 years ago
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Table2 = var _table1={1} var _table1date= CALENDAR( MINX(FILTER(ALL('Table'),'Table'[CarNr]=1),[Date]), MAXX(ALL('Table'),'Table'[Date])) var _table2={2} var _table2date= CALENDAR( MINX(FILTER(ALL('Table'),'Table'[CarNr]=2),[Date]), MAXX(ALL('Table'),'Table'[Date])) return UNION( CROSSJOIN( _table1,_table1date) , CROSSJOIN( _table2,_table2date))2. Create calculated column.
Used = var _value= MAXX( FILTER(ALL('Table'), 'Table'[CarNr]=EARLIER('Table2'[Value])&&'Table'[Date]=EARLIER('Table2'[Date])),[Distance]) return IF( _value=BLANK(),BLANK(),1)Available = var _mindate=MINX(FILTER(ALL('Table'),'Table'[CarNr]=EARLIER('Table2'[Value])),[Date]) return IF( 'Table2'[Date]>=_mindate&&'Table2'[Date]<=MAXX(ALL('Table'),'Table'[Date]),1,0)3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Anonymous
3 years agoNot applicable
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Table2 =
var _table1={1}
var _table1date=
CALENDAR(
MINX(FILTER(ALL('Table'),'Table'[CarNr]=1),[Date]),
MAXX(ALL('Table'),'Table'[Date]))
var _table2={2}
var _table2date=
CALENDAR(
MINX(FILTER(ALL('Table'),'Table'[CarNr]=2),[Date]),
MAXX(ALL('Table'),'Table'[Date]))
return
UNION(
CROSSJOIN(
_table1,_table1date)
,
CROSSJOIN(
_table2,_table2date))
2. Create calculated column.
Used =
var _value=
MAXX(
FILTER(ALL('Table'),
'Table'[CarNr]=EARLIER('Table2'[Value])&&'Table'[Date]=EARLIER('Table2'[Date])),[Distance])
return
IF(
_value=BLANK(),BLANK(),1)Available =
var _mindate=MINX(FILTER(ALL('Table'),'Table'[CarNr]=EARLIER('Table2'[Value])),[Date])
return
IF(
'Table2'[Date]>=_mindate&&'Table2'[Date]<=MAXX(ALL('Table'),'Table'[Date]),1,0)
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly