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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
George1973
Helper V
Helper V

Summarization for Measure Does not Work

Hi Guys,

I have a measure counting sales ever existence number of month having sales activity within last 3 months.

 

1st 3_M WoUsg = 
VAR FMnCount3 =
UNION(
   ROW("MTV",[-1M]),
   ROW("MTV",[-2M]),
   ROW("MTV",[Sold Prod Qnty])
  )

Return
CAlculate(COUNTAX(FMnCount3,[MTV]),FILTER(FMnCount3,[MTV]>0))

And it's fine. It's beeing calculated for each product.

But the problem is I can not sum the whole mesaure number.

George1973_0-1650626342857.png

As you can see, by rows I'm getting the right number,  but in the Column total I have no summary.
Even when I try to get a result in a "Card Visual" I have only 3 as result.

Please help in solving this issue.

Thanks in advance,



2 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @George1973 

you may try 

1st 3_M WoUsg =
VAR FMnCount3 =
    UNION (
        ROW ( "MTV", [-1M] ),
        ROW ( "MTV", [-2M] ),
        ROW ( "MTV", [Sold Prod Qnty] )
    )
RETURN
    SUMX (
        VALUES ( Table[Code] ),
        CALCULATE ( COUNTAX ( FMnCount3, [MTV] ), FILTER ( FMnCount3, [MTV] > 0 ) )
    )

View solution in original post

@tamerj1 
I think I found an alternative solution. At least for the final purpose, it is more than enough:

Month Usage Sum = 

VAR FMG=ADDCOLUMNS(allselected(C_GOODS[პროდუქციის კოდი]),"Pr_Code",C_GOODS[პროდუქციის კოდი],"3M_Usg",[1st 3_M WoUsg],"12M_Usg",[1st Y_M WoUsg])
VAR Sum12M=sumX(filter(FMG,[12M_Usg]=12),[3M_Usg])
VAR Sum11M=sumX(filter(FMG,[12M_Usg]=11),[3M_Usg])
VAR Sum10M=sumX(filter(FMG,[12M_Usg]=10),[3M_Usg])
VAR Sum9M=sumX(filter(FMG,[12M_Usg]=9),[3M_Usg])
VAR Sum8M=sumX(filter(FMG,[12M_Usg]=8),[3M_Usg])
VAR Sum7M=sumX(filter(FMG,[12M_Usg]=7),[3M_Usg])
VAR Sum6M=sumX(filter(FMG,[12M_Usg]=6),[3M_Usg])
VAR Sum5M=sumX(filter(FMG,[12M_Usg]=5),[3M_Usg])
VAR Sum4M=sumX(filter(FMG,[12M_Usg]=4),[3M_Usg])
VAR Sum3M=sumX(filter(FMG,[12M_Usg]=3),[3M_Usg])
VAR Sum2M=sumX(filter(FMG,[12M_Usg]=2),[3M_Usg])
VAR Sum1M=sumX(filter(FMG,[12M_Usg]=1),[3M_Usg])
VAR Sum0M=sumX(filter(FMG,[12M_Usg]=0),[3M_Usg])

Return
Sum11M

First it calculates the grand total sum for the the months with existing sales and then, I can refer to the SUMS with the second criteria from [12M_Usg].. be it 1, 2,3... or 12..
The final result has been achieved. That's all I wanted! :))) Thanks a lot again1

View solution in original post

25 REPLIES 25
tamerj1
Super User
Super User

@George1973 

Try is simple by referring to old measure

1st 3_M WoUsg new =
SUMX ( VALUES ( Table[Code] ), [1st 3_M WoUsg] )

@tamerj1 ,
Unfotunately the results with the newest (simle) formula got worse (Differences increase)

 

Month Usage Sum = SUMX ( VALUES (C_GOODS[პროდუქციის კოდი]), [1st 3_M WoUsg] )

 

Can you place both measures in a separate matix along with the codes in the rows

Like that?

George1973_0-1650638133898.png

 

I mean copy the matrix and remove everything except the the old and the new measures

Code1st 3_M WoUsgMonth Usage Sum
0027311
005921 
0126911
0129311
0131133
0131222
0131433
013461 
0155822
0156811
015691 
0157033
0157133
0157833
0158022
0158133
0158322
0159311
018432 
0198733
019961 
0271422
027161 
0284722
0298222
0331011
033581 
033711 
0337233
0343722
0351511
035161 
0351711
0358622
0377133
0388411
038921 
0389933
0395033
0395422
040481 
041281 
0450833
0450933
045341 
0458311
0479033
0479111
0483033
0483411
049641 
0496811
049691 
0497011
0509933

@George1973 

It could be the variable that is blocking the contrxt transition. Try

1st 3_M WoUsg =
SUMX (
    VALUES ( Table[Code] ),
    CALCULATE (
        COUNTAX ( FMnCount3, [MTV] ),
        FILTER (
            UNION (
                ROW ( "MTV", [-1M] ),
                ROW ( "MTV", [-2M] ),
                ROW ( "MTV", [Sold Prod Qnty] )
            ),
            [MTV] > 0
        )
    )
)

@tamerj1 

:)))))))

Unfotunately, absolutely the same result and the same differences..

I'm going slightly mad 

I don't know why it behaved this way. Maybe we can connect tomorrow and find a solution. 

tamerj1
Super User
Super User

Hi @George1973 

you may try 

1st 3_M WoUsg =
VAR FMnCount3 =
    UNION (
        ROW ( "MTV", [-1M] ),
        ROW ( "MTV", [-2M] ),
        ROW ( "MTV", [Sold Prod Qnty] )
    )
RETURN
    SUMX (
        VALUES ( Table[Code] ),
        CALCULATE ( COUNTAX ( FMnCount3, [MTV] ), FILTER ( FMnCount3, [MTV] > 0 ) )
    )

@tamerj1 

Again, no improvement 😞

George1973_0-1650645350149.png

Some logic, As I wrote you before, is that, the mistake happens when there is a blank result in [Sold Prod Qnty] result, but not always.. But why it is so, I have no clue..
Ok, we have spent a whole day in solving it.. I do not want to bother you anymore.

Thank you very much again for your support and proffesionalism. I do realy appriciate it.

Try wrap the formula with KEEPFILTERS

Like that?

Month Usage Sum = 
VAR FMnCount3 =
    UNION (
                ROW ( "MTV", [Sold Prod Qnty] ),
                ROW ( "MTV", [-1M] ),
                ROW ( "MTV", [-2M] )
    )
RETURN
   SUMX (
    VALUES ( C_GOODS[პროდუქციის კოდი] ),
    CALCULATE (
        COUNTAX ( FMnCount3, [MTV] ),
        KEEPFILTERS(
        FILTER (
            UNION (
                ROW ( "MTV", [Sold Prod Qnty] ),
                ROW ( "MTV", [-1M] ),
                ROW ( "MTV", [-2M] )
            ),
            [MTV] > 0
        )
    )
)
   )

Still does not work 😞

 

@tamerj1 
I think I found an alternative solution. At least for the final purpose, it is more than enough:

Month Usage Sum = 

VAR FMG=ADDCOLUMNS(allselected(C_GOODS[პროდუქციის კოდი]),"Pr_Code",C_GOODS[პროდუქციის კოდი],"3M_Usg",[1st 3_M WoUsg],"12M_Usg",[1st Y_M WoUsg])
VAR Sum12M=sumX(filter(FMG,[12M_Usg]=12),[3M_Usg])
VAR Sum11M=sumX(filter(FMG,[12M_Usg]=11),[3M_Usg])
VAR Sum10M=sumX(filter(FMG,[12M_Usg]=10),[3M_Usg])
VAR Sum9M=sumX(filter(FMG,[12M_Usg]=9),[3M_Usg])
VAR Sum8M=sumX(filter(FMG,[12M_Usg]=8),[3M_Usg])
VAR Sum7M=sumX(filter(FMG,[12M_Usg]=7),[3M_Usg])
VAR Sum6M=sumX(filter(FMG,[12M_Usg]=6),[3M_Usg])
VAR Sum5M=sumX(filter(FMG,[12M_Usg]=5),[3M_Usg])
VAR Sum4M=sumX(filter(FMG,[12M_Usg]=4),[3M_Usg])
VAR Sum3M=sumX(filter(FMG,[12M_Usg]=3),[3M_Usg])
VAR Sum2M=sumX(filter(FMG,[12M_Usg]=2),[3M_Usg])
VAR Sum1M=sumX(filter(FMG,[12M_Usg]=1),[3M_Usg])
VAR Sum0M=sumX(filter(FMG,[12M_Usg]=0),[3M_Usg])

Return
Sum11M

First it calculates the grand total sum for the the months with existing sales and then, I can refer to the SUMS with the second criteria from [12M_Usg].. be it 1, 2,3... or 12..
The final result has been achieved. That's all I wanted! :))) Thanks a lot again1

Hi @tamerj1 again,

 

Sorry for disturbing you again, but the measure gives error in some cases:

 

George1973_0-1650633868667.png

The column, Marked with yellow color is the right (old) result and the column with blue, is the new measure results.. as you can see, there are blanks, instead of the right figures.

@George1973 

Can you please paste the code you have used in a reply? Are sure you are using the correct column reference in the code? Is there any other column involved in the tsummary table?

@tamerj1 ,
Here is the code new code (Developed by You):

 

And Here is the old code:

 

Please note that:

George1973_0-1650635177182.png

The marked one is the reference to Product-Code

 

 

 

Sorry, the codes seems to be deleted:

Month Usage Sum = 
VAR FMnCount3 =
UNION(
   ROW("MTV",[-1M]),
   ROW("MTV",[-2M]),
   ROW("MTV",[Sold Prod Qnty])
  )
VAR TotRes=sumX (
        VALUES (C_GOODS[პროდუქციის კოდი]),
        CALCULATE ( COUNTX ( FMnCount3, [MTV] ), FILTER ( FMnCount3, [MTV] > 0 ) )
    )


    

//VAR Usg12=CALCULATE(TotRes,filter(ALLSELECTED(C_GOODS),[1st Y_M WoUsg]=12))
return
TotRes

 

(Your Code)

 

1st 3_M WoUsg = 
VAR FMnCount3 =
UNION(
   ROW("MTV",[-1M]),
   ROW("MTV",[-2M]),
   ROW("MTV",[Sold Prod Qnty])
  )

VAR TotRes=calculate(COUNTAX ( FMnCount3, [MTV] ), FILTER ( FMnCount3, [MTV] <> BLANK() ))
    

Return
TotRes

Old code

 

 

One hint,
What I found out is that, the differences are in the cases, where [Sold Prod Qnty] is blank.
Meaning, that:
1. All differnces happen with the blank [sold prod qnty] 
2. All blank [sold prod qnty] cases are not differences

Meybe it happens because the Product Codes are in TEXT format? (Just an Idea)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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