Forum Discussion
Macesa
6 years agoRegular Visitor
CALCULAR SUBTOTALES EN UNA MATRIZ
Hola buen día colegas. Quizás me pueden ayudar con lo siguiente: Tengo una matriz en Power BI que tiene el campo Municipio en ROW y en Values tiene tres campos: 1.- Personas, 2.- % que es un...
- 6 years ago
Hi Macesa ,
I'll show you a workaround to do it:
First create a table such as below:
Putting all the fields of column "Municipio" with nu3 rows of "subtotal" in it ,adding an index column in query editor,then modify your measure as below:
Measure 2 = IF ( ISINSCOPE ( 'Table (3)'[Column1] ), IF ( FIND ( "total", SELECTEDVALUE ( 'Table (3)'[Column1] ), 1, -1 ) > 0, VAR currentTotalIndex = MIN ( 'Table (3)'[Index] ) VAR lastTotalIndex = CALCULATE ( MAX ( 'Table (3)'[Index] ), FILTER ( ALLSELECTED ( 'Table (3)' ), 'Table (3)'[Index] < currentTotalIndex && FIND ( "total", [Column1], 1, -1 ) > 0 ) ) + 0 RETURN CALCULATE ( SUM ( 'Table (3)'[value] ), FILTER ( ALLSELECTED ( 'Table (3)' ), 'Table (3)'[Index] > lastTotalIndex && 'Table (3)'[Index] < currentTotalIndex ) ), SUM ( 'Table (3)'[value] ) ), CALCULATE ( SUM ( 'Table (3)'[value] ), FILTER ( 'Table (3)', FIND ( "total", [Column1], 1, -1 ) = -1 ) ) )Finally you will see:
Here is the related .pbix file.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
v-kelly-msft
Community Support
6 years agoHi Macesa ,
I'll show you a workaround to do it:
First create a table such as below:
Putting all the fields of column "Municipio" with nu3 rows of "subtotal" in it ,adding an index column in query editor,then modify your measure as below:
Measure 2 =
IF (
ISINSCOPE ( 'Table (3)'[Column1] ),
IF (
FIND ( "total", SELECTEDVALUE ( 'Table (3)'[Column1] ), 1, -1 ) > 0,
VAR currentTotalIndex =
MIN ( 'Table (3)'[Index] )
VAR lastTotalIndex =
CALCULATE (
MAX ( 'Table (3)'[Index] ),
FILTER (
ALLSELECTED ( 'Table (3)' ),
'Table (3)'[Index] < currentTotalIndex
&& FIND ( "total", [Column1], 1, -1 ) > 0
)
) + 0
RETURN
CALCULATE (
SUM ( 'Table (3)'[value] ),
FILTER (
ALLSELECTED ( 'Table (3)' ),
'Table (3)'[Index] > lastTotalIndex
&& 'Table (3)'[Index] < currentTotalIndex
)
),
SUM ( 'Table (3)'[value] )
),
CALCULATE (
SUM ( 'Table (3)'[value] ),
FILTER ( 'Table (3)', FIND ( "total", [Column1], 1, -1 ) = -1 )
)
)
Finally you will see:
Here is the related .pbix file.
Best Regards,
Kelly
Kelly
Did I answer your question? Mark my post as a solution!