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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
parry2k
Super User
Super User

% of total by category by year

Hello all,

 

it seems to be very easy but somehow I'm unable to figure out.

 

I have data in following format where invoice amount is for whole month. I want to calculate invoice amount fo each category by

 

Category share =  total minutes of category / (sum of total minutes of category by year and month)

 

Category Amount = invoice amount * Category Share

 

Here is sample data

 

Year   Month  Category   Total Minutes   Invoice Amount   

2015    1         A                1000               20000

2015    1         B                2000               20000

2015    2         A                1000               10000

2015    2         B                2000               10000

2015    2         C                2000               10000

 

Here is the end result

 

Year   Month  Category   Total Minutes   Invoice Amount      Category Share    Category Amount

2015    1         A                1000               20000                      0.33                               6666.67

2015    1         B                2000               20000                      0.67                             13333.33 

2015    2         A                1000               10000                      0.17                               1666.67

2015    2         B                2000               10000                      0.33                               3333.33

2015    2         C                2000               10000                      0.50                               5000.00

 

Help please!

 

Thanks,

Parvinder

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

1 ACCEPTED SOLUTION

I tried the solution and created a new measure and put it in matrix which matches the total calculated by matrix. But challenge here is when I'm filtering on a category it is applying that filter on new calculated measure field which I don't want. 

 

Not sure if I'm doing something wrong here.

 

Thanks,



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
Haegi
Advocate V
Advocate V

Hi,

 

It's possible to use Measure column and DAX language.

 

To calculate the cumulative value "total minutes of category" you can use this formula below

http://www.daxpatterns.com/cumulative-total/

 

Example (personal)

Cumulative = CALCULATE(SUM(mAggregate[aggAmount]); FILTER(ALL(dDates[Date]); dDates[Date] <= MAX(dDates[Date])))

 

The value of measure is recalculated normaly for each Category.

You can test with a matrix tab.

 

After you can create another measure like this

CategoryShare = TotalMinute/Cumulative

 

For the last column i don't know if a measure if necessary or if a calculated column is enought.

 

Hope it will help you.

Regards.

I tried the solution and created a new measure and put it in matrix which matches the total calculated by matrix. But challenge here is when I'm filtering on a category it is applying that filter on new calculated measure field which I don't want. 

 

Not sure if I'm doing something wrong here.

 

Thanks,



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Seems like  I figure it out, will keep posted here after solution worked for me.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi,

 

Normaly a measure depend to a particular context .

But it's work properly with any filters if the column in measure and the filter provide of the same table i thinks or distinct tables if it existist a relation between.

 

Regards.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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