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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

DAX unpivot

Hi 

 

In the DAX formula I would like to have the effect of a column that identify the "transaction"/accounting type.

the column would contain eg Gross UPR movement, GrossPremium and RIIBNRMove next to the relevant rows.

 

please help! 🙂

 

Screenshot_1.png

 

1 ACCEPTED SOLUTION

HI  @Anonymous 

You could try this formula:

Table = 
UNION( 
SELECTCOLUMNS(FACT_Sales,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","Sales","Amount",[SalesAmount]),

SELECTCOLUMNS(FACT_CostOfSales,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","CostOfSales","Amount",[CostOfSalesAmount]),

SELECTCOLUMNS(FACT_AdminCosts,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","AdminCosts","Amount",[AdminCosts]

))

 

result:

3.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

View solution in original post

8 REPLIES 8
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

If you want to use dax to unpivot the table, you could refer to this blog:

https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/td-p/574832

 

And if you want to get further help, please share your sample data and your expected output.

Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Pragati11
Super User
Super User

Hi @Anonymous ,

 

I don't understand what you are trying to ask here. Please refer following link on how to post your query:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 

 

I posted a detailed reply, but somehow it was marked as spam by the website.

Is it possible to "unspam" my reply?

Hi @Anonymous ,

 

I can't see your response.

May be try posting it again or message admin.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

this response keeps getting marked as spam
@Pragati11  @v-lili6-msft 

how do I contact administrator?

nikilouwgmail_0-1600850691999.png

 

Anonymous
Not applicable

hi @Pragati11 , @v-lili6-msft 

 

- I need to group by multiple DIM and FACT tables and then unpivot it using DAX

- Unfortunately I cant use the GROUP BY and UNPIVOT functions in PowerQuery due my work being done in Visual Studio/Analysis Services as a Tabular model (compatibility limited to 2016 for our clients, otherwise I could use PowerQuery)


- DIM_Tables:  DIM_Product: ID, ProductName ;

                        DIM_Company: ID, CompanyName ;

                        DIM_AccountingPeriod: ID, AccPeriodMonth

 

- FACT Tables: FACT_Sales:            ProductID, CompanyID, AccPeriodMonthID, SalesAmount ; 

                        FACT_CostOfSales: ProductID, CompanyID, AccPeriodMonthID, CostOfSalesAmount ;

                        FACT_AdminCosts: ProductID, CompanyID, AccPeriodMonthID, AdminCosts

 

- I need the following output:

 

ProductName  |   AccPeriodMonth   |    Companyname   |    TransactionType               |   Amount

1                      |     Jan20                   |        A                     |       Sales                              |     100
2                      |     Jan20                   |        A                     |       CostOfSales                   |       50
3                      |     Jan20                   |        A                     |       AdminCosts                   |       20
1                      |     Feb20                  |        A                      |       Sales                              |     200
2                      |     Feb20                  |        A                      |       CostOfSales                   |       70
3                      |     Feb20                  |        A                      |      AdminCosts                    |       30
1                      |     Jan20                   |        B                     |       Sales                              |     100
2                      |     Jan20                   |        B                     |       CostOfSales                   |       50
3                      |     Jan20                   |        B                     |       AdminCosts                   |       20
1                      |     Feb20                  |        B                      |       Sales                              |     200
2                      |     Feb20                  |        B                      |       CostOfSales                   |       70
3                      |     Feb20                  |        B                      |      AdminCosts                    |       30

 

I appreciate the help.

Thank you in advance

HI  @Anonymous 

You could try this formula:

Table = 
UNION( 
SELECTCOLUMNS(FACT_Sales,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","Sales","Amount",[SalesAmount]),

SELECTCOLUMNS(FACT_CostOfSales,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","CostOfSales","Amount",[CostOfSalesAmount]),

SELECTCOLUMNS(FACT_AdminCosts,"ProductName",RELATED(DIM_Product[ProductName]),"AccPeriodMonth",RELATED(DIM_AccountingPeriod[AccPeriodMonth]),"Companyname",RELATED(DIM_Company[CompanyName]),"TransactionType","AdminCosts","Amount",[AdminCosts]

))

 

result:

3.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you very much @v-lili6-msft 
Much appreciated.
I can see it works, but perhaps my data set is too large or complex, because it won't execute the DAX. It hangs and then crashes.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.