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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
misen08
Frequent Visitor

Add columns to "pivot table"

Hi,

 

I'm trying to add calculated columns to 2 merged tables with Power Query to simulate a pivot table. The custom columns are:

 

Indisponibilite: [Congé]+[Réunion]+[Maladie]
Disponibilité: [Nombre employés]*7.5
Taux disponibilité: (1-[Indisponibilté]/[Disponibilté])*100

 

The only way I could do this in Excel was to add formulas alongside the pivot table.

Is there any solution to do this in Power Bi?

 

Here's the Excel file:

https://ufile.io/5oped

2 ACCEPTED SOLUTIONS
v-lili6-msft
Community Support
Community Support

HI, @misen08

After my test, you could do these follow my steps as below:

Step1:

If you column Code absence and column Date?

IF not, then remove one of them and then select column Catégorie click Transform->Pivot table

Values Column: The remaining one column( Code absence or Date), Aggregate Value Function : Count(All) 

7.JPG

Click "OK"

8.JPG

Step2:

Cloes&Apply

Step3:

Create a relationship between T_Catégories with T_Métiers

9.JPG

Step4:

Create calculate measure:

Indisponibilite: [Congé]+[Réunion]+[Maladie]
Disponibilité: [Nombre employés]*7.5
Taux disponibilité: (1-[Indisponibilté]/[Disponibilté])*100

Indisponibilite = CALCULATE(SUM([Congé]))+CALCULATE(SUM([Réunion]))+CALCULATE(SUM([Maladie]))

Disponibilité = Disponibilité = CALCULATE(SUM('T_Métiers'[Nombre])*7.5)

Taux disponibilité = AVERAGEX(SUMMARIZE('T_Catégories','T_Catégories'[Métier]), (1-[Indisponibilite]/[Disponibilité])*100)

Result:

11.JPG

By the way, Let me explain why we don't use merge function and create column instead of Create the relationship and calculate measure? If use merge function and create column, we couldn't filter by month, for it will lead to duplicate value. Unless you do not filter result, you could use merge function and create column.

 

here is my pbix, please try it.

https://www.dropbox.com/s/66jlstvsmymsznb/Add%20columns%20to%20pivot%20table.pbix?dl=0

 

Best 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

misen08
Frequent Visitor

Hi,

 

I'm trying to add custom columns to a table made from 2 merged table of data with Power Query to simulate a pivot table.

 

Calculated columns:

Indisponibilite: [Congé]+[Réunion]+[Maladie]
Disponibilité: [Nombre employés]*7.5
Taux disponibilité: (1-[Indisponibilté]/[Disponibilté])*100

 

I can't seem to find any work around in Power Bi to do this.

In Excel, the only way I found was to add formulas alongside the pivot table.

Is there any solution to this in Power Bi?

 

Here's the Excel file with an example of what I'm trying to achieve:

https://ufile.io/5oped

 

Example.png

 

Thanks.

View solution in original post

3 REPLIES 3
misen08
Frequent Visitor

Hi,

 

I'm trying to add custom columns to a table made from 2 merged table of data with Power Query to simulate a pivot table.

 

Calculated columns:

Indisponibilite: [Congé]+[Réunion]+[Maladie]
Disponibilité: [Nombre employés]*7.5
Taux disponibilité: (1-[Indisponibilté]/[Disponibilté])*100

 

I can't seem to find any work around in Power Bi to do this.

In Excel, the only way I found was to add formulas alongside the pivot table.

Is there any solution to this in Power Bi?

 

Here's the Excel file with an example of what I'm trying to achieve:

https://ufile.io/5oped

 

Example.png

 

Thanks.

v-lili6-msft
Community Support
Community Support

HI, @misen08

After my test, you could do these follow my steps as below:

Step1:

If you column Code absence and column Date?

IF not, then remove one of them and then select column Catégorie click Transform->Pivot table

Values Column: The remaining one column( Code absence or Date), Aggregate Value Function : Count(All) 

7.JPG

Click "OK"

8.JPG

Step2:

Cloes&Apply

Step3:

Create a relationship between T_Catégories with T_Métiers

9.JPG

Step4:

Create calculate measure:

Indisponibilite: [Congé]+[Réunion]+[Maladie]
Disponibilité: [Nombre employés]*7.5
Taux disponibilité: (1-[Indisponibilté]/[Disponibilté])*100

Indisponibilite = CALCULATE(SUM([Congé]))+CALCULATE(SUM([Réunion]))+CALCULATE(SUM([Maladie]))

Disponibilité = Disponibilité = CALCULATE(SUM('T_Métiers'[Nombre])*7.5)

Taux disponibilité = AVERAGEX(SUMMARIZE('T_Catégories','T_Catégories'[Métier]), (1-[Indisponibilite]/[Disponibilité])*100)

Result:

11.JPG

By the way, Let me explain why we don't use merge function and create column instead of Create the relationship and calculate measure? If use merge function and create column, we couldn't filter by month, for it will lead to duplicate value. Unless you do not filter result, you could use merge function and create column.

 

here is my pbix, please try it.

https://www.dropbox.com/s/66jlstvsmymsznb/Add%20columns%20to%20pivot%20table.pbix?dl=0

 

Best 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.

Hi,

 

Thanks for the file and clear explanation! It is what I'm looking for!

I just have a question...I don't understand what you mean by " If you column Code absence and column Date?"

 

Misen


@v-lili6-msft wrote:

HI, @misen08

After my test, you could do these follow my steps as below:

Step1:

If you (Missing word) column Code absence and column Date?

IF not, then remove one of them and then select column Catégorie click Transform->Pivot table

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.