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
Analitika
Post Prodigy
Post Prodigy

Mesuare sum each by grup with filter

I have a table

DateNameCodeSubNameCode NameName PriceSub nameSubName pricePcs
4349010070131 Tea Salary0,0617050
43490100706000 Tea Sticker10,0011852010
4349010070421000 Tea Stick10,001942400
434901007010070 Tea0,31777  2000
434901007020310001 Tea Leaf10,204945102500
4349010070401000 Tea Stick20,0042753520
4349010070310050 Tea Box10,043722024
4349010070  Tea  02000
43490100706032 Tea  00
4351410070131 Tea Salary0,0608830
43514100706000 Tea Sticker10,0011871024
435141007020310001 Tea Leaf10,0037881793
4351410070401000 Tea Stick20,20119751250
435141007010070 Tea0,30843  1019
4351410070310050 Tea Box10,041374976
4351410070  Tea  01019
43514100706032 Tea  00

 

Need measure to get sum of each Subname by SubName price and Sum of each SubName Pcs
so must be something like that

AllSubNamePrice =
Calculate(

SUM([SubnamePrice]),
FIlter([NameCode]<>[SubNameCode]),
)

AllSubNameCount =
Calculate(

SUM([Pcs]),
FIlter([NameCode]<>[SubNameCode]),
)

1pcsPrice =
Divide(

AllSubNamePrice ,
AllSubNameCount ), // if  "Salary", then get value from [Pcs] where [NameCode]=[SubNameCode]
)

But measure sum all alue but not by group and dates

 

Expected result is:

Sub nameSumCount1pcs
Salary         0,1226 €                      -     0,0614276 €
Box1         0,0851 €                3 000   0,0000284 €
Leaf1         0,2087 €           104 293   0,0000020 €
Stick1         0,0019 €                2 400   0,0000008 €
Stick2         0,2055 €             54 770   0,0000038 €
Sticker1         0,0024 €                3 034   0,0000008 €
1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Analitika 

 

Based on your description, you may create three measures as below.

AllSubNamePrice = 
CALCULATE(
    SUM('Table'[SubName price]),
    FILTER(
        'Table',
        'Table'[NameCode]<>'Table'[SubNameCode]
    )
)
AllSubNameCount = 
IF(
    SELECTEDVALUE('Table'[Sub name])<>"Salary",
    CALCULATE(
        SUM('Table'[Pcs]),
        FILTER(
            'Table',
            'Table'[Name Price]<>'Table'[SubNameCode]
        )
    ),
    CALCULATE(
                SUM('Table'[Pcs]),
                FILTER(
                    ALL('Table'),
                    'Table'[NameCode]='Table'[SubNameCode]
                )
    )
)
1pcsPrice = 
IF(
    NOT(ISBLANK(SELECTEDVALUE('Table'[Sub name]))),
    DIVIDE(
            [AllSubNamePrice],
            [AllSubNameCount]
    )
)

 

Result:

c1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @Analitika 

 

Based on your description, you may create three measures as below.

AllSubNamePrice = 
CALCULATE(
    SUM('Table'[SubName price]),
    FILTER(
        'Table',
        'Table'[NameCode]<>'Table'[SubNameCode]
    )
)
AllSubNameCount = 
IF(
    SELECTEDVALUE('Table'[Sub name])<>"Salary",
    CALCULATE(
        SUM('Table'[Pcs]),
        FILTER(
            'Table',
            'Table'[Name Price]<>'Table'[SubNameCode]
        )
    ),
    CALCULATE(
                SUM('Table'[Pcs]),
                FILTER(
                    ALL('Table'),
                    'Table'[NameCode]='Table'[SubNameCode]
                )
    )
)
1pcsPrice = 
IF(
    NOT(ISBLANK(SELECTEDVALUE('Table'[Sub name]))),
    DIVIDE(
            [AllSubNamePrice],
            [AllSubNameCount]
    )
)

 

Result:

c1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank You, Works good, except finding PCS for Salary, always zeroes. But needed find value wich in column PCS with same date, but not All() need be in group by Name.

 

So must be something like:

If SubName = "Salary" Then take value from column PCS where 'Table'[NameCode]='Table'[SubNameCode] and same date

 

that because i need blanks too

 

 

Untitled.png

 

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.