Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
v_mark
Helper V
Helper V

Is there any DAX alternative to PIVOT?

Just wondering if there is an alternative in PIVOT inside power query by using DAX?

I know using PIVOT inside PQ is so much easier.

Just wanna know if there's another approach to come up with the desired result. 🙂

 

Originally my table looks like this 

v_mark_0-1632258554796.png

 

the expected output below w/c I was able to achieve by using pivot.

v_mark_1-1632258594437.png

 

1 ACCEPTED SOLUTION
moizsherwani
Continued Contributor
Continued Contributor

@v_mark  there certainly is (if there number of pivoted columns are known in advance). See screenshot and code below. Note: this is a new table which needs to be created

 

Regards,

 

Moiz

If this post helps, please "Accept" it as Solution to help other members find it.

 

moizsherwani_0-1632260065401.png

 

 

SampleDataPivoted = 
SUMMARIZE (
    SampleData,
    SampleData[ParentPublicID],
    "Status", MIN ( SampleData[Status] ),
    "Status_1", MIN ( SampleData[Status_1] ),
    "Diagnosis",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Diagnosis"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Repair",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Repair"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Recovery",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Recovery"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Testing",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Testing"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        )
)

 

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

View solution in original post

3 REPLIES 3
v-xiaoyan-msft
Community Support
Community Support

Hi @v_mark ,

 

Does the replies above solve your problem? If it has been solved, please mark the correct reply as the standard answer to help the other members find it more quickly.Thank you very much for your kind cooperation!

 

Hope it helps,


Community Support Team _ Caitlyn

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

moizsherwani
Continued Contributor
Continued Contributor

@v_mark  there certainly is (if there number of pivoted columns are known in advance). See screenshot and code below. Note: this is a new table which needs to be created

 

Regards,

 

Moiz

If this post helps, please "Accept" it as Solution to help other members find it.

 

moizsherwani_0-1632260065401.png

 

 

SampleDataPivoted = 
SUMMARIZE (
    SampleData,
    SampleData[ParentPublicID],
    "Status", MIN ( SampleData[Status] ),
    "Status_1", MIN ( SampleData[Status_1] ),
    "Diagnosis",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Diagnosis"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Repair",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Repair"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Recovery",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Recovery"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        ),
    "Testing",
        CALCULATE (
            MIN ( SampleData[TaskID] ),
            FILTER (
                SampleData,
                SampleData[Title] = "Testing"
                    && SampleData[ParentPublicID] = [ParentPublicID]
            )
        )
)

 

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.
FAY2020
Resolver I
Resolver I

You should be able to use a Matrix visual to achieve this. Put ParentPublicID, Status and Status_1 as rows, Title as columns and TaskID as values.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.