cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

## Create a Measure Using Two Other Measures but One Ignores a Filter

Hello everyone,

I have a table with numerous, but simple measures and different categorization columns. The two measures I need to use are for number of certificates and number of denials. Both are using similar count functions, CALCULATE(COUNT('Table'[ID]),FILTER('Table','Table'[Qualifier]="Cert")) and CALCULATE(COUNT('Table'[ID]),FILTER('Table','Table'[Qualifier]="Denial")). My problem is that I need to find the Cert Rate, Certs/(Certs + Denials), in a matrix that has the Year/Quarter and U.S. State as rows and Cert Category in the column, however the Cert Rate must be calculated using the total Certs + Denials across each row (so the total for each state, year, and quarter).

The problem I have is two-fold. The first is that I need it to calculate the Cert Rate across the entire column, as in the total of (Certs + Denials) must ignore the Cert Category, and second is that the Denials records do not have a Cert Category associated with them (the value for Cert Category is blank whereas for Certs records, there is always a value). They are all in one large table.

I have tried looking at different topics, but couldn't find one that has the same issue.

The data table is similar to this:

TL:DR
I have these two matrixes and need to get the third one calculated from Certs/(Certs+Denials) across the rows

1 ACCEPTED SOLUTION
Community Support

Hi, @ngoodweiler

Based on your description, and the data you provided, I tried to create two matrices like yours using the following sample data:

I created a measure using the following DAX expression:

``````MEASURE =
VAR _table =
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[State],
'Table'[Date],
"Year", YEAR ( 'Table'[Date] ),
"Denis Total",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[Qualifier] = "Denial" )
)
)
VAR _table1 =
SUMMARIZE (
_table,
'Table'[State],
[Year],
"Denis",
VAR _current_year = [Year]
VAR _state = 'Table'[State]
RETURN
SUMX (
FILTER ( _table, 'Table'[State] = _state && [Year] = _current_year ),
[Denis Total]
)
)
VAR _table2 =
FILTER (
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[State],
'Table'[Category],
'Table'[Date],
"Year", YEAR ( 'Table'[Date] ),
"value", CALCULATE ( SUM ( 'Table'[value] ) )
),
'Table'[Category] <> BLANK ()
)
VAR _table3 =
SUMMARIZE (
_table2,
'Table'[State],
'Table'[Category],
[Year],
"value1",
VAR _current_year = [Year]
VAR _state = 'Table'[State]
VAR _category = 'Table'[Category]
RETURN
SUMX (
FILTER (
_table2,
'Table'[Category] = _category
&& 'Table'[State] = _state
&& [Year] = _current_year
),
[value]
)
)
VAR _current_state =
SELECTEDVALUE ( 'Table'[State] )
VAR _current_year =
SELECTEDVALUE ( 'Table'[Date].[Year] )
VAR _current_category =
SELECTEDVALUE ( 'Table'[Category] )
VAR _table4 =
FILTER ( _table1, 'Table'[State] = _current_state && [Year] = _current_year )
VAR _table5 =
FILTER (
_table3,
'Table'[State] = _current_state
&& 'Table'[Category] = _current_category
&& [Year] = _current_year
)
VAR _dens =
CALCULATE ( MAXX ( _table4, [Denis] ) )
RETURN
DIVIDE (
MAXX ( _table5, [value1] ),
_dens
+ SUMX (
FILTER ( _table3, 'Table'[State] = _current_state && [Year] = _current_year ),
[value1]
)
)
``````

Put this measure in the matrix and the result is as follows:

I've provided the PBIX file used this time below.

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

2 REPLIES 2
Community Support

Hi, @ngoodweiler

Based on your description, and the data you provided, I tried to create two matrices like yours using the following sample data:

I created a measure using the following DAX expression:

``````MEASURE =
VAR _table =
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[State],
'Table'[Date],
"Year", YEAR ( 'Table'[Date] ),
"Denis Total",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[Qualifier] = "Denial" )
)
)
VAR _table1 =
SUMMARIZE (
_table,
'Table'[State],
[Year],
"Denis",
VAR _current_year = [Year]
VAR _state = 'Table'[State]
RETURN
SUMX (
FILTER ( _table, 'Table'[State] = _state && [Year] = _current_year ),
[Denis Total]
)
)
VAR _table2 =
FILTER (
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[State],
'Table'[Category],
'Table'[Date],
"Year", YEAR ( 'Table'[Date] ),
"value", CALCULATE ( SUM ( 'Table'[value] ) )
),
'Table'[Category] <> BLANK ()
)
VAR _table3 =
SUMMARIZE (
_table2,
'Table'[State],
'Table'[Category],
[Year],
"value1",
VAR _current_year = [Year]
VAR _state = 'Table'[State]
VAR _category = 'Table'[Category]
RETURN
SUMX (
FILTER (
_table2,
'Table'[Category] = _category
&& 'Table'[State] = _state
&& [Year] = _current_year
),
[value]
)
)
VAR _current_state =
SELECTEDVALUE ( 'Table'[State] )
VAR _current_year =
SELECTEDVALUE ( 'Table'[Date].[Year] )
VAR _current_category =
SELECTEDVALUE ( 'Table'[Category] )
VAR _table4 =
FILTER ( _table1, 'Table'[State] = _current_state && [Year] = _current_year )
VAR _table5 =
FILTER (
_table3,
'Table'[State] = _current_state
&& 'Table'[Category] = _current_category
&& [Year] = _current_year
)
VAR _dens =
CALCULATE ( MAXX ( _table4, [Denis] ) )
RETURN
DIVIDE (
MAXX ( _table5, [value1] ),
_dens
+ SUMX (
FILTER ( _table3, 'Table'[State] = _current_state && [Year] = _current_year ),
[value1]
)
)
``````

Put this measure in the matrix and the result is as follows:

I've provided the PBIX file used this time below.

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

Regular Visitor

This was great, thank you for the help!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.