March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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))))
Solved! Go to Solution.
Hi @apup,
Could you try using the formula below to create the measure to see if it works?
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
Hi @apup,
Could you try using the formula below to create the measure to see if it works?
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
146 | |
97 | |
79 | |
69 |