PBI Measure as a Value in Matrix Visual

Viewed 52

I appreciate some help with the below problem. I have the table

Month Line Amount
Jan ST 20
Jan AB 10
Jan AC 2
Jan AG 15
Feb ST 40
Feb AB 20
Feb AC 4
Feb AG 8
Mar ST 65
Mar AB 5
Mar AC 6
Mar AG 2

and I want a Matrix

Jan Feb Mar
AB 50.00% 50.00% 7.69%
AC 10.00% 10.00% 9.23%
AG 75.00% 20.00% 3.08%

The Value of the Matrix is a Mesure

(%) Amount ST =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( table1[Line] ) = "AB",
        DIVIDE (
            SUM ( table1[Amount] ),
            CALCULATE ( SUM ( table1[Amount] ), FILTER ( 'table1', table1[Line] = "ST" ) )
        ),
    SELECTEDVALUE ( table1[Line] ) = "AC",
        DIVIDE (
            SUM ( table1[Amount] ),
            CALCULATE ( SUM ( table1[Amount] ), FILTER ( 'table1', table1[Line] = "ST" ) )
        ),
    SELECTEDVALUE ( table1[Line] ) = "AG", DIVIDE ( SUM ( table1[Amount] ), 4 ),
    SUM ( table1[Amount] )
)

The measure works fine for AG, to test it I used in the denominator the number 4, but when I added the calculate function to filter by ST I didn't see it in the visual ???

Any ideas

Thank you OJ

1 Answers

I'm not sure what are you calculating. From your measure, is this is what are you looking for?

DAX Calculation

(%) Amount ST = 
VAR STAmount =
    CALCULATE ( SUM ( table1[Amount] ), table1[Line] = "ST" )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( table1[Line] ) = "AB", DIVIDE ( SUM ( table1[Amount] ), STAmount ),
        SELECTEDVALUE ( table1[Line] ) = "AC", DIVIDE ( SUM ( table1[Amount] ), STAmount ),
        SELECTEDVALUE ( table1[Line] ) = "AG", DIVIDE ( SUM ( table1[Amount] ), STAmount ),
        SUM ( table1[Amount] )
    )

Output

enter image description here

Related