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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Removefilters?? All??? AllSelected??? which to use?

Question:  How do I modify my measure to ignore the date slicer?

 

Details:

I have a cluster chart that captures the average number of tickets per week of the month for this month and last month.  I am also trying to add a line that captures the average number of tickets per week of the month for ALL months, but I can't seem to make it work.  I'm not sure which command function to use or where to apply it within the formula.

 

Ruthie09_0-1652793728935.png

 

Here is the data that drives the bars above in table format since I can't upload anything to the cloud.  

Ruthie09_1-1652793943189.png

As you can see from the chart above, because April is selected in the Date slicer, I'm getting the correct bar values but the line chart is simply using the selected month.  What I need is for the line chart to pick up these values (which are the weekly average counts for all months):

 

Ruthie09_2-1652794212494.png

The measure to modify:

This is the formula that drives the above Weekly Avg I want:

_Inc SC Avg Count by W# = AVERAGEX ( VALUES( 'DATE Table'[_Date SC Week of Month (# only)] ), 'Incident Measures'[_Inc Count] ) / [_Count of Months]

 

The biggest hurdles I'm facing right now is that (1) all the parts of my above measure are also measures (2) that if I remove any of the date filters, the other parts of the formula don't work and (3) what I want to ignore is a slicer (I think, for example, that REMOVEFILTERS only works on actual filters, but I'm not sure).

30 REPLIES 30
tamerj1
Super User
Super User

@Anonymous 

Please try this

_Inc SC Avg Count by W# =
AVERAGEX (
    CALCULATETABLE (
        VALUES ( 'DATE Table'[_Date SC Week of Month (# only)] ),
        ALLEXCEPT ( 'DATE Table', 'DATE Table'[_Date SC Week of Month (# only)] )
    ),
    [_Inc Count]
) / [_Count of Months]
Anonymous
Not applicable

Nope.  I'm going to go do lunch now.  I'll be back in about an hour.  This whole thing is both fun and frustrating at the same time.

@Anonymous 

For me it's time to go sleep. However, please share code for the "count of month" measure. I think my first solution which resulted in large values can result in correct numbers if divided over the correct number of months (6). The first value for example (42.298) if divided over 6 will result in 7.05 which is the value you get when you select all the months (no selection in the slicer). 

Anonymous
Not applicable

I am still nowhere on this.  It really should be easier but I'm beginning to wonder if the functionality is broken in the April 2022 version because EVERYTHING I have seen has said that it should work.

 

As for Count of Month, I posted the formula in another answer but here it is again:

_Count of Months = COUNTROWS(VALUES('DATE Table'[Year Month Name]))

 

My current idea (but ran out of time today) was to create another little table with just the W1, W2, etc. column and the inc count / count of months formula and then relate it to my main either the date table or the source data table.

 

 

_Count of Months = COUNTROWS(ALL('DATE Table'[Year Month Name]))

Anonymous
Not applicable

@tamerj1 

 

I'm still completely stuck.  I'm going to re-post the issue and see if anyone else has any ideas.  heavy sigh.

daXtreme
Solution Sage
Solution Sage

This won't work?

 

[Meas] = 
CALCULATE(
    [_Inc SC Avg Count by W#],
    // just remove the filter
    // that comes from the slicer...
    ALL( Dates[Month] )
)

You just have to remove the filter from the value Apr-2022. Then, the measure above should see all the months and only the week that's on the x-axis.

 

Anonymous
Not applicable

That's what I thought too but the following doesn't work (where Year Month Name is the column in my date table that is the slicer):

 

_Inc SC Avg Count by W# 2 = CALCULATE('Incident Measures'[_Inc SC Avg Count by W#],ALL('DATE Table'[Year Month Name]))

Hi @Anonymous 
Please provide some sample data

Anonymous
Not applicable

The column headers run together but they are

Year Month Name

_Date SC Week of Month (W#)

_Inc Count

 

Year Month Name_Date SC Week of Month (W#)_Inc Count
Dec-21W12,841
Dec-21W27,503
Dec-21W37,417
Dec-21W45,226
Jan-22W16,482
Jan-22W27,896
Jan-22W38,501
Jan-22W410,396
Feb-22W18,439
Feb-22W28,636
Feb-22W38,614
Feb-22W48,199
Mar-22W18,232
Mar-22W28,166
Mar-22W38,434
Mar-22W413,457
Apr-22W18,733
Apr-22W28,028
Apr-22W37,328
Apr-22W49,620
May-22W17,571
May-22W26,758

 

The date table contains the following entry that drives the date slicer:

 

DATE Table =

var _fromYear=2020

var _toYear=YEAR(TODAY())

var _today=TODAY()

 

return

ADDCOLUMNS(

    CALENDAR(

                DATE(_fromYear,5,1),

                DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))),

"Year Month Name",FORMAT([Date],"MMM-YYYY"),

)

Hi @Anonymous 
Please try

_Inc SC Avg Count by W# =
AVERAGEX (
    VALUES ( 'DATE Table'[_Date SC Week of Month (# only)] ),
    CALCULATE ( [_Inc Count], ALL ( 'DATE Table'[Year Month Name] ) )
) / [_Count of Months]
Anonymous
Not applicable

@tamerj1 

 

😕 It still returns the values from the month selected in the date slicer.

 

Please please please keep trying.

@Anonymous 
I think you have more columns in the date table than mentioned in the code. Howeve, Please try

_Inc SC Avg Count by W# =
AVERAGEX (
    VALUES ( 'DATE Table'[_Date SC Week of Month (# only)] ),
    CALCULATE (
        [_Inc Count],
        ALLEXCEPT ( 'DATE Table', 'DATE Table'[_Date SC Week of Month (# only)] )
    )
) / [_Count of Months]
Anonymous
Not applicable

That returned this:

Ruthie09_0-1652801625562.png

 

Yes, my date table has many more columns and quite a few measures:

 

This is my master table with other relevant extra columns added at the bottom (I made it smaller to take up less space):

 

DATE Table =
var _fromYear=2020
var _toYear=YEAR(TODAY())
var _today=TODAY()
 
return
ADDCOLUMNS(
CALENDAR(
DATE(_fromYear,5,1),
DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))),
"Year",YEAR([Date]),
"Start of Year",DATE( YEAR([Date]),1,1),
"End of Year",DATE( YEAR([Date]),12,31),
"Month",MONTH([Date]),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1),
"End of Month",EOMONTH([Date],0),
"Days in Month",DATEDIFF(DATE( YEAR([Date]), MONTH([Date]), 1),EOMONTH([Date],0),DAY)+1,
"Year Month Number",INT(FORMAT([Date],"YYYYMM")),
"Year Month Name",FORMAT([Date],"MMM-YYYY"),
"Date (dd-mmm-yy)",[Date],
"Day",DAY([Date]),
"Day Name Long",FORMAT([Date],"DDDD"),
"Day Name Short",FORMAT([Date],"DDD"),
"Day of Week",WEEKDAY([Date]),
"Day of Year",DATEDIFF(DATE( YEAR([Date]), 1, 1),[Date],DAY)+1,
"Month Name Long",FORMAT([Date],"MMMM"),
"Month Name Short",FORMAT([Date],"MMM"),
"Quarter",QUARTER([Date]),
"Quarter Name","Q"&FORMAT([Date],"Q-YYYY"),
"Year Quarter Number",INT(FORMAT([Date],"YYYYQ")),
"Year Quarter Name",FORMAT([Date],"YYYY")&" Q"&FORMAT([Date],"Q"),
"Start of Quarter",DATE( YEAR([Date]), (QUARTER([Date])*3)-2, 1),
"End of Quarter",EOMONTH(DATE( YEAR([Date]), QUARTER([Date])*3, 1),0),
"Week of Year",WEEKNUM([Date]),
"Start of Week", [Date]-WEEKDAY([Date],3),
"End of Week",[Date]-WEEKDAY([Date],3)+6,
"End of Week (dd-mmm-yy)",[Date]-WEEKDAY([Date],3)+6,
"Day Offset",DATEDIFF(_today,[Date],DAY),
"Month Offset",DATEDIFF(_today,[Date],MONTH),
"Quarter Offset",DATEDIFF(_today,[Date],QUARTER),
"Year Offset",DATEDIFF(_today,[Date],YEAR)
)
 
Other key date columns and measures:
_Date SC Week of Month (W#) = IF(DIVIDE(CEILING(DAY('DATE Table'[Date]),7),7) >= 4, "W4", "W" & DIVIDE(CEILING(DAY('DATE Table'[Date]),7),7))
 
_Date SC Week of Month (# only) = IF(DIVIDE(CEILING(DAY('DATE Table'[Date]),7),7) >= 4, 4, DIVIDE(CEILING(DAY('DATE Table'[Date]),7),7))
 
_Count of Months = COUNTROWS(VALUES('DATE Table'[Year Month Name]))
 
_Inc Count = IF (ISBLANK (DISTINCTCOUNT ('INCIDENTS'[INC_NUMBER])), BLANK(), DISTINCTCOUNT ('INCIDENTS'[INC_NUMBER]))
 
The column called "Week" is the  _Date SC Week of Month (W#)  column.
Count of Months and Inc Count are both measures.
Anonymous
Not applicable

@tamerj1 

For what it's worth, when I trigger the slashed circle on the table (with the date slicer selected), the results are what we want.  Unfortunately, we need that functionality to work on the measure itself.

@Anonymous 

There should be a solution. Please try

_Inc SC Avg Count by W# =
CALCULATE (
    AVERAGEX (
        VALUES ( 'DATE Table'[_Date SC Week of Month (# only)] ),
        [_Inc Count]
    ),
    ALLEXCEPT ( 'DATE Table', 'DATE Table'[_Date SC Week of Month (# only)] )
) / [_Count of Months]
Anonymous
Not applicable

There has to be a solution but so far, nada.  This produced the overall average for each week from the previous measure:

Ruthie09_0-1652804122687.png

 

@Anonymous 

We will keep trying

_Inc SC Avg Count by W# =
AVERAGEX (
    VALUES ( 'DATE Table'[_Date SC Week of Month (# only)] ),
    CALCULATE (
        [_Inc Count],
        ALLEXCEPT ( 'DATE Table', 'DATE Table'[_Date SC Week of Month (# only)] )
    )
)
    / CALCULATE (
        [_Count of Months],
        ALLEXCEPT ( 'DATE Table', 'DATE Table'[_Date SC Week of Month (# only)] )
    )
Anonymous
Not applicable

@tamerj1 

 

THANK YOU FOR STAYING WITH THIS!!!!  😟 This time we got the daily average, I think:

 

Ruthie09_0-1652805974278.png

 

@Anonymous 

Actually no this is not the daily average. This is the sum of the 6 months weekly averages divided by the total number of year-months in your date table which I can accurately calculate as 26 months. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.