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
Ion_Ander
Helper I
Helper I

summarize ignore slicer

Hi,
I have a measure that calculates the number of customers who lower purchases compared to the previous year.
But the problem is that i have slicer with the year in the report. so I need to ignore the year filter in the measure, but don´t know how.

This is my measure:

N_Clients_decrease= 
 CALCULATE(
    COUNTROWS(SUMMARIZE(CLI,CLI[CODCLI])),
    FILTER(SUMMARIZE(CLI,CLI[CODCLI]),[INCREASE]<0)
    )

The  year comes from another table (calendar Table) named DimDate that is related with CLI table by the date
*[INCREASE]=YearToDate-YearToDateLastYear

1 ACCEPTED SOLUTION

Hi @Ion_Ander ,

 

I try another method, and the formula is:

 

DecreaseMeasure = 
VAR sel = SELECTEDVALUE(DimDate2[Year])
var emp = SELECTEDVALUE(EMPRES[NAME])
var tab = 
    CALCULATETABLE(
        SUMMARIZE(
            CLIENT,
            CLIENT[CODCLI],
            "LYTYTD", 
                CALCULATE(
                    SUM(CLIENT[IMPNET]),
                    FILTER(
                        ALL(CLIENT),
                        CLIENT[CODCLI] = MAX(CLIENT[CODCLI])
                        && CLIENT[EMPRESA] = emp
                        && YEAR(CLIENT[FECALB]) = sel-1
                    )
                ),
            "TYTD",
                CALCULATE(
                    SUM(CLIENT[IMPNET]),
                    FILTER(
                        ALL(CLIENT),
                        CLIENT[CODCLI] = MAX(CLIENT[CODCLI])
                        && CLIENT[EMPRESA] = emp
                        && YEAR(CLIENT[FECALB]) = sel
                    )
                )
        ),
        FILTER( ALL(CLIENT), YEAR(CLIENT[FECALB]) > 2019 && CLIENT[EMPRESA] = emp ),
        GROUPBY( DimDate2, DimDate2[QuarterFullName] )
    )
return COUNTROWS( FILTER( tab, [LYTYTD] > [TYTD] ) )

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

5 REPLIES 5
amitchandak
Super User
Super User

@Ion_Ander , Try like

countx(values(CLI[CODCLI]),if([INCREASE] <0, [CODCLI], blank()))

 

Hope your measure is correct

 

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

@amitchandak  Thanks for your replay, it still does not work as I hope ,

I have the same problem with your measure, i need to ignore the filter how came form a slicer with the year, thats becasuse if a client do not have sold in the year its considered as a decrease.

This slicer is filtering the sales table so that those customers without sales in the year are not taken into account. This is why i need to ignore the year filter.
In this snapshoot you can see the result is the same

Ion_Ander_0-1621331487337.png

and the reult mus be 934.

YTD=CALCULATE(sum(CLI[IMPNET]), DATESYTD(DimDate2[DateFull]))

Last YTD=CALCULATE ( [YTD], SAMEPERIODLASTYEAR ( 'DimDate2'[DateFull] ) )


One more time Thanks, its not what desired, but its more simple and probably more efficient.

Hi @Ion_Ander ,

 

Try the following formula:

INCREASE = 
VAR CurrentYear = SUM(CLI[VALUE])
VAR Previous_Year = 
    CALCULATE(
        SUM(CLI[VALUE]),
        ALL(CLI),
        PREVIOUSYEAR(CLI[DATE]),
        GROUPBY( CLI, CLI[CODCLI] )
    )
RETURN CurrentYear - Previous_Year
N_Clients_decrease = 
CALCULATE(
    COUNTROWS(CLI),
    FILTER(CLI,[INCREASE]<0)
)

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

 

THANKS @v-kkf-msft but something not not working as expected, the number of decreeasing clients is to hight, i share the PBIX file to see.

 

https://a31069321-my.sharepoint.com/:u:/g/personal/ionander_gabyl_com/Eag3xi-Q20dDk5RQsuoXR8QBR9u7OK... 

 

What I expect is the result of the DECREASE SUMMARIZECOLUMN measure, which you can see in the attachment, but I cannot use this measure in a matrix, the summarizecolumn seems not compatible with the matrix.

Hi @Ion_Ander ,

 

I try another method, and the formula is:

 

DecreaseMeasure = 
VAR sel = SELECTEDVALUE(DimDate2[Year])
var emp = SELECTEDVALUE(EMPRES[NAME])
var tab = 
    CALCULATETABLE(
        SUMMARIZE(
            CLIENT,
            CLIENT[CODCLI],
            "LYTYTD", 
                CALCULATE(
                    SUM(CLIENT[IMPNET]),
                    FILTER(
                        ALL(CLIENT),
                        CLIENT[CODCLI] = MAX(CLIENT[CODCLI])
                        && CLIENT[EMPRESA] = emp
                        && YEAR(CLIENT[FECALB]) = sel-1
                    )
                ),
            "TYTD",
                CALCULATE(
                    SUM(CLIENT[IMPNET]),
                    FILTER(
                        ALL(CLIENT),
                        CLIENT[CODCLI] = MAX(CLIENT[CODCLI])
                        && CLIENT[EMPRESA] = emp
                        && YEAR(CLIENT[FECALB]) = sel
                    )
                )
        ),
        FILTER( ALL(CLIENT), YEAR(CLIENT[FECALB]) > 2019 && CLIENT[EMPRESA] = emp ),
        GROUPBY( DimDate2, DimDate2[QuarterFullName] )
    )
return COUNTROWS( FILTER( tab, [LYTYTD] > [TYTD] ) )

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

 

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.