cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors