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
apup
Regular Visitor

Using ALLEXCEPT with DATESBETWEEN - Don't understand scope of ALLEXCEPT

Let's say I have a widget factory, and it produces different types of widgets. I would like a measure that returns the percentage of one type of widget produced against all types widgets produced. E.g. 

 

I have this formula

 

Widgets1Mth = DIVIDE(CALCULATE(COUNT(Widget[WidgetId]),DATESBETWEEN('Date'[Date],DATE(YEAR(TODAY()),MONTH(TODAY())-1,1),EOMONTH(TODAY(),-1))),CALCULATE(COUNTX(ALLEXCEPT(Widget,Widget[CreatedDate]),Widget[WidgetId]),DATESBETWEEN('Date'[Date],DATE(YEAR(TODAY()),MONTH(TODAY())-1,1),EOMONTH(TODAY(),-1))))

 

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @apup,

 

Could you try using the formula below to create the measure to see if it works? Smiley Happy

Widgets1Mth =
VAR currentType =
    FIRSTNONBLANK ( Widget[Type], 1 )
RETURN
    DIVIDE (
        CALCULATE (
            COUNT ( Widget[WidgetId] ),
            FILTER (
                ALL ( 'Widget' ),
                Widget[CreatedDate]
                    >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 )
                    && Widget[CreatedDate] <= EOMONTH ( TODAY (), -1 )
                    && Widget[Type] = currentType
            )
        ),
        CALCULATE (
            COUNT ( Widget[WidgetId] ),
            FILTER (
                ALL ( 'Widget' ),
                Widget[CreatedDate]
                    >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 )
                    && Widget[CreatedDate] <= EOMONTH ( TODAY (), -1 )
            )
        )
    )

 

Regards

View solution in original post

1 REPLY 1
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @apup,

 

Could you try using the formula below to create the measure to see if it works? Smiley Happy

Widgets1Mth =
VAR currentType =
    FIRSTNONBLANK ( Widget[Type], 1 )
RETURN
    DIVIDE (
        CALCULATE (
            COUNT ( Widget[WidgetId] ),
            FILTER (
                ALL ( 'Widget' ),
                Widget[CreatedDate]
                    >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 )
                    && Widget[CreatedDate] <= EOMONTH ( TODAY (), -1 )
                    && Widget[Type] = currentType
            )
        ),
        CALCULATE (
            COUNT ( Widget[WidgetId] ),
            FILTER (
                ALL ( 'Widget' ),
                Widget[CreatedDate]
                    >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 )
                    && Widget[CreatedDate] <= EOMONTH ( TODAY (), -1 )
            )
        )
    )

 

Regards

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.