Forum Discussion
campelliann
Post Patron
4 years agoNew column returning always the same value on a virtual table
Hi there, I have this table with project data, where each project lives on one row. I have several columns for each row, amongs them the beginning and ending date. Table Sample Project ID ...
- 4 years ago
campelliann I believe you want something like this:
Table = VAR __Project = SELECTEDVALUE('Triskall Complete'[Process]) VAR __Table = ADDCOLUMNS( FILTER('Triskall Complete',[Process] = __Project), "__Days",([End Date] - [Start Date]) + 0 ) RETURN __Table
campelliann
Post Patron
4 years ago
Hi ValtteriN. First and foremost thanks, I have been around this problem for a couple of days and this driving me crazy 🙂 Now I get only 1s in the last column. Note that I am trying to build a Virtual Table for a more complex problem. I just created this physical table to check how the virtual table looks. It seems that in the virtual table I am not creating a row by row count of the days...
ValtteriN
Community Champion
4 years agoHi campelliann
I think the problem is with the SELECTEDVALUE. In the filter context you are applying it now it returns blank.
You don't often need the intermediary var step in your virtual table.
E.G.
Datediff from virtual table = var _table = ADDCOLUMNS(Projects_v,"_Time",DATEDIFF(Projects_v[Start],Projects_v[End],DAY)+1) return
SUMX(_table,[_Time])