Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
campelliann
Post Patron
Post Patron

Dax "Puzzle" 2 - Help with virtual Table

Project Table

ProjectBeginning DateEnd Date 
Project A1 jun5jun 
Project B1april10 april 

 

(Virtual Table)

ProjectBeginning DateEnd DateTotal Days
Project A1 jun5jun5
Project B1april10 april10 

 

So I need to create a virtual Table where I add a column with the total days for each project, something along these lines:

 

var virtual table: ADDCOLUMNS(Project Table, "@Total Days", Countrows(datesbetween(Dates, Selectedvalue(Beginning Date),Selectedvalue( End date),) 

Then I want to sum the newly virtual column, that in this particular case would be 5+10 = 15,


I tried with a variable "current_project" to make the Datesbetween work, and get the total days for each project row by row. But the measure does not work in the totals, and in the charts only works If I place "Project" as legend.... If I do not filter per project, it does not work.

Any help?

Many thanks

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You were close. Here's your measure

 

 

Total Days = int(SUMX(ADDCOLUMNS('Project Table',"Days",'Project Table'[End Date]-'Project Table'[Beginning Date]+1),[Days]))

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

You were close. Here's your measure

 

 

Total Days = int(SUMX(ADDCOLUMNS('Project Table',"Days",'Project Table'[End Date]-'Project Table'[Beginning Date]+1),[Days]))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.