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
Riddler
Frequent Visitor

Calculate SUMX & VALUES & Filter EARLIER

Hi I have a table Projectshistorical with severall ProjectIds in it.

projectdetails.projectIdrepositories.repo.locrepositories.repo.scantimestampRollProjectLoc
36925812.04.2019 09:1869258
32238012.04.2019 09:1969258+22380
36925812.04.2019 09:3769258+22380
36925812.04.2019 09:5069258+22380
32238012.04.2019 09:5469258+22380
313602312.04.2019 09:5569258+22380+136023
32238012.04.2019 10:0669258+22380+136023
313602312.04.2019 10:1069258+22380+136023
 
RollProjectLoc = CALCULATE(
SUMX(
VALUES('Projectshistorical'[projectdetails.projectId]);[repositories.repo.loc]);
FILTER('Projectshistorical';'Projectshistorical'[repositories.repo.scantimestamp]<=EARLIER(Projectshistorical[repositories.repo.scantimestamp])))
 
And it always gives me the answer that it cannot find the repositories.repo.loc if I create a quick measure it tells me that this is a ring dependency...  How do I make this work?
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Riddler ,

 

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] )

Capture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

7 REPLIES 7
marab
New 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

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @Riddler ,

 

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] )

Capture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
v-frfei-msft
Community Support
Community Support

Hi @Riddler ,

 

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] )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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. 

Hi @Riddler ,

 

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] )

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi  @v-frfei-msft  thanks for this fast reply.

 

I tried it.

RollingProjectRepoLoc = 
VAR cal =
    CALCULATETABLE (
        DISTINCT ( 'Projectshistorical'[repositories.repo.loc] );
        FILTER (
            ALLSELECTED ( 'Projectshistorical' );
            'Projectshistorical'[repositories.repo.scantimestamp]
                <= MAX ( 'Projectshistorical'[repositories.repo.scantimestamp] )
        );
        VALUES ( 'Projectshistorical'[projectdetails.projectId] )
    )
RETURN
    SUMX ( cal; 'Projectshistorical'[repositories.repo.loc] )

Which gave me back this table (results are far right)

projectdetails.projectIdrepositoryIdrepositories.repo.repositoryNamerepositories.repo.locrepositories.repo.scantimestampRollingProjectRepoLoc
411angular TS8618318.04.2019 12:39664378
38hbase13602312.04.2019 09:55664378
38hbase13602312.04.2019 10:10664378
38hbase13602316.04.2019 15:02664378
38hbase13602316.04.2019 15:16664378
38hbase13602329.04.2019 12:35664378
48hbase13602312.04.2019 09:55664378
48hbase13602312.04.2019 10:10664378
48hbase13602316.04.2019 15:02664378
48hbase13602316.04.2019 15:16664378
48hbase13602329.04.2019 12:35664378
11Kafka13697009.04.2019 20:33664378
11Kafka13697009.04.2019 20:52664378
41Kafka13697009.04.2019 20:33664378
41Kafka13697009.04.2019 20:52664378
35hivemall(incubating)6925812.04.2019 09:18664378
35hivemall(incubating)6925812.04.2019 09:37664378
35hivemall(incubating)6925812.04.2019 09:43664378
35hivemall(incubating)6925812.04.2019 09:50664378
11Kafka13697018.04.2019 17:54664378
41Kafka13697018.04.2019 17:54664378
11Kafka13697029.04.2019 12:29664378
41Kafka13697029.04.2019 12:29664378
11Kafka13697029.04.2019 14:30664378
41Kafka13697029.04.2019 14:30664378
23lgv11161810.04.2019 15:28664378
23lgv11161810.04.2019 17:20664378
23lgv11161829.04.2019 14:27664378
24ol-cesium491110.04.2019 16:52664378
36skywalking (incubating)1236112.04.2019 09:19664378
36skywalking (incubating)1236112.04.2019 09:39664378
36skywalking (incubating)1236112.04.2019 09:45664378
36skywalking (incubating)1236112.04.2019 09:54664378
36skywalking (incubating)1236112.04.2019 10:06664378
36skywalking (incubating)1236116.04.2019 15:13664378
36skywalking (incubating)1236116.04.2019 15:15664378
36skywalking (incubating)1236129.04.2019 12:50664378
49three152118.04.2019 09:11664378
49three152118.04.2019 12:39664378
410Visual Studio10553318.04.2019 09:12

664378

So the value what is calculated is the sum of all repo.locs that are distinct. 

I have the feeling that this goes in the right direction.

As you can see in this table there are different projectsIds and different repoIds . Where I want to sum up the last timestamps repo.locs for each project with its distinct repositories and make it a rolling value.  

 

Thanks for all the help you put into this.

Greets Riddler

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.