Forum Discussion
Calculate SUMX & VALUES & Filter EARLIER
Hi I have a table Projectshistorical with severall ProjectIds in it.
| projectdetails.projectId | repositories.repo.loc | repositories.repo.scantimestamp | RollProjectLoc |
| 3 | 69258 | 12.04.2019 09:18 | 69258 |
| 3 | 22380 | 12.04.2019 09:19 | 69258+22380 |
| 3 | 69258 | 12.04.2019 09:37 | 69258+22380 |
| 3 | 69258 | 12.04.2019 09:50 | 69258+22380 |
| 3 | 22380 | 12.04.2019 09:54 | 69258+22380 |
| 3 | 136023 | 12.04.2019 09:55 | 69258+22380+136023 |
| 3 | 22380 | 12.04.2019 10:06 | 69258+22380+136023 |
| 3 | 136023 | 12.04.2019 10:10 | 69258+22380+136023 |
Hi Anonymous ,
Please check the sample pbix as attached. If it doesn't meet your requirement, kindly share your excepted result to me.
Measure = VAR cal = CALCULATETABLE ( DISTINCT ( 'Projectshistorical'[repositories.repo.loc] ), FILTER ( ALLSELECTED ( Projectshistorical ), 'Projectshistorical'[repositories.repo.scantimestamp] <= MAX ( 'Projectshistorical'[repositories.repo.scantimestamp] ) ), VALUES ( Projectshistorical[repositoryId] ) ) RETURN SUMX ( cal, 'Projectshistorical'[repositories.repo.loc] )
7 Replies
- v-frfei-msft
Community Support
Hi Anonymous ,
To create a measure as below.
Measure = VAR cal = CALCULATETABLE ( DISTINCT ( 'Table1'[repositories.repo.loc] ), FILTER ( ALLSELECTED ( Table1 ), 'Table1'[repositories.repo.scantimestamp] <= MAX ( 'Table1'[repositories.repo.scantimestamp] ) ) ) RETURN SUMX ( cal, 'Table1'[repositories.repo.loc] )- AnonymousNot applicable
Hi v-frfei-msft
Wow this looks great and very promising, but it seems not to take into account that I also need to filter on the project ID but instead filters on distinct values of repo.loc. What can happen is that two repos are used in different projects or that two repos in the same project have the same repo.loc. In my table I have also different projects, what I wrote in the text, what was probably a bit misleading. Should have made more examples in the table. My apologies.
So I tried to make it Distinct by project ID but then it actually multiplies repo.loc with the project.id. Do you know how I can make it work?
RollingLOC = VAR cal = CALCULATETABLE ( DISTINCT ( 'Projectshistorical'[projectdetails.projectId]); FILTER ( ALLSELECTED ( Projectshistorical ); 'Projectshistorical'[repositories.repo.scantimestamp] <= MAX ( 'Projectshistorical'[repositories.repo.scantimestamp] ) ) ) RETURN SUMX ( cal; 'Projectshistorical'[repositories.repo.loc])Thanks a lot in advance. This is completely different from how I tried to do that.- v-frfei-msft
Community Support
Hi Anonymous ,
Update the formula as below.
Measure = VAR cal = CALCULATETABLE ( DISTINCT ( 'Table1'[repositories.repo.loc] ), FILTER ( ALLSELECTED ( Table1 ), 'Table1'[repositories.repo.scantimestamp] <= MAX ( 'Table1'[repositories.repo.scantimestamp] ) ), VALUES ( 'Projectshistorical'[projectdetails.projectId] ) ) RETURN SUMX ( cal, 'Table1'[repositories.repo.loc] )
- v-frfei-msft
Community Support
Hi Anonymous ,
Please check the sample pbix as attached. If it doesn't meet your requirement, kindly share your excepted result to me.
Measure = VAR cal = CALCULATETABLE ( DISTINCT ( 'Projectshistorical'[repositories.repo.loc] ), FILTER ( ALLSELECTED ( Projectshistorical ), 'Projectshistorical'[repositories.repo.scantimestamp] <= MAX ( 'Projectshistorical'[repositories.repo.scantimestamp] ) ), VALUES ( Projectshistorical[repositoryId] ) ) RETURN SUMX ( cal, 'Projectshistorical'[repositories.repo.loc] ) - marabNew Member
Hi all,
I have a problem with the formula below that should be correct but it doesn't recongnize the column name in the EARLIER function.
I simply need to sum up the Item Value per each project name like:
Project Name Item Item Value Project Value
A 1 50 89
A 2 39 89
B 1 10 100
B 2 50 100
B 3 40 100
Project Value = Sumx(FILTER('Tab_Project','Tab_Project'[Project Name]=EARLIER('Tab_Project'[Project Name],'Tab_Project'[Item Value]))Any clue?a million thanks- Ashish_Mathur
Super User
Hi,
If you want a calculated column formula, then try this
=calculate(sum('Tab_Project'[Item Value]),FILTER('Tab_Project','Tab_Project'[Project Name]=EARLIER('Tab_Project'[Project Name])))
If you want a measure, then try this
=calculate(sum('Tab_Project'[Item Value]),allexcept('Tab_Project','Tab_Project',['Tab_Project'[Item]]))
Hope this helps.