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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
sabeensp
Helper IV
Helper IV

Group Records by Month then calculate Percent

I have a very simple problem that I'm strugling to resolve.

 

I have a follwing Table Called Payroll

 

Month ------ Dept ------- Amount
1-2019------ Fin ------- 50

1-2019------ Hr ------- 35

1-2019------ Mkt ------- 15

2-2019------ Fin------- 20

2-2019------ Hr------- 55

2-2019------ Mkt------- 25

 

I need follwing result

Month ------ Dept ------- Amount ---- Percent
1-2019------ Fin ------- 115 ---- 69% (Becuase 115 of 165 total of 1-2019)

1-2019------ Hr ------- 35 ------ 21.21% (Becuase 35 of 165 total of 1-2019)

1-2019------ Mkt ------- 15------ 9.09% (Becuase 15 of 165 total of 1-2019)

2-2019------ Fin------- 120  -- so on

2-2019------ Hr------- 25 -- so on 

2-2019------ Mkt------- 20 -- so on 

 

So basically, I want to get % at each month level.

 

Thanks

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @sabeensp ,

 

You need to add the following measure to your model:

% over month =
SUM ( Payroll[Amount] )
    / CALCULATE ( SUM ( Payroll[Amount] ); ALLEXCEPT ( Payroll; Payroll[Month] ) )

Another option is this:

% over month =
SUM ( Payroll[Amount] )
    CALCULATE (
        SUM ( Payroll[Amount] );
        ALL ( Payroll[Month]; Payroll[Dept] );
        VALUES ( Payroll[Month] )
    )

Both give the same result but based on the size of your table they can provide different performance.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @sabeensp ,

 

You need to add the following measure to your model:

% over month =
SUM ( Payroll[Amount] )
    / CALCULATE ( SUM ( Payroll[Amount] ); ALLEXCEPT ( Payroll; Payroll[Month] ) )

Another option is this:

% over month =
SUM ( Payroll[Amount] )
    CALCULATE (
        SUM ( Payroll[Amount] );
        ALL ( Payroll[Month]; Payroll[Dept] );
        VALUES ( Payroll[Month] )
    )

Both give the same result but based on the size of your table they can provide different performance.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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