Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Pivot transformation

Hello

 

I have the data:

 

Field1Field2Field3Field4Attribute1Attribute2Attribute3
1234  Yes
2344YesYes 
3454 Yes 

 

I want to transform the above into:

 Attribute1Attribute2Attribute3
 Yes(blank)Yes(blank)Yes(blank)
Count of Field1 where Field2 is >2112000

 

I would like to do that with Measures or DAX rather than Power Query, any idea?

 

Thanks!

2 Replies

  • Please explain what you mean by "Count of Field1" - maybe COUNTROWS() ?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please refer to my pbix file to see if it helps you.

    Create columns.

    blank_1 =
    CALCULATE (
        COUNT ( 'Table'[Field1] ),
        'Table'[Field2] > 2
            && 'Table'[Attribute1] = BLANK ()
    )
    
    _1yes =
    VAR _count =
        CALCULATE (
            COUNT ( 'Table'[Field1] ),
            FILTER ( 'Table', 'Table'[Field2] > 2 && 'Table'[Attribute1] = "Yes" )
        )
    RETURN
        IF ( 'Table'[Attribute1] = "Yes", _count, BLANK () )
    
    blank_2 =
    CALCULATE (
        COUNT ( 'Table'[Field1] ),
        FILTER ( 'Table', 'Table'[Field2] > 2 && 'Table'[Attribute2] = BLANK () )
    )
    
    _2yes =
    VAR _count =
        CALCULATE (
            COUNT ( 'Table'[Field1] ),
            FILTER ( 'Table', 'Table'[Field2] > 2 && 'Table'[Attribute2] = "Yes" )
        )
    RETURN
        IF ( 'Table'[Attribute2] = "Yes", _count, BLANK () )
    
    blank_3 =
    VAR count_ =
        CALCULATE (
            COUNT ( 'Table'[Field1] ),
            FILTER ( 'Table', 'Table'[Field2] > 2 && 'Table'[Attribute3] = BLANK () )
        )
    RETURN
        IF ( 'Table'[Attribute3] = BLANK (), count_, BLANK () )
    
    _3yes =
    VAR _count =
        CALCULATE (
            COUNT ( 'Table'[Field1] ),
            FILTER ( 'Table', 'Table'[Field2] > 2 && 'Table'[Attribute3] = "Yes" )
        )
    RETURN
        IF ( 'Table'[Attribute3] = "Yes", _count, BLANK () )
    

     

    If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.

     

    Best Regards

    Community Support Team _ Polly

     

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