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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
KSt
Frequent Visitor

YTD where months are column headings

Hi,

 

I'm fairly new to Power BI, so would appreciate some help. I have a budget table (simplified example below) and I'd like a calculation to show my total budget for the year to date.

 

So in July I'd want the Fundraising YTD budget to show £4000 and the Finance YTD budget to show £1450. I'd like this to automatically update itself each month.

 

NLCCNameProjectDeptApr-16May-16Jun-16Jul-16Aug-16Sep-16etc
40001FundraisingCLSVol100010001000100010001000 
40011FinanceCLSAcc850 600 916  
40022SalesMTAcc500500500500500500 
40034TelephoneBRInt100  100   

 

 Thank you for your help

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

Hi @KSt,

 

From your description, it seems you are using the matrix to display the values, and the “Apr-16”,”May-16”,…. come from one column field, right?

 

Assume the sample data likes below:

 

q4.PNG

 

You can create a measure like this:

 

Cumulative = CALCULATE(SUM(Table1[Value]),FILTER(ALL('Table1'),'Table1'[Date]<=MAX('Table1'[Date])),VALUES(Table1[NL]),VALUES(Table1[CC]),VALUES(Table1[Name]),VALUES(Table1[Project]),VALUES(Table1[Dept]))

 

Then create a matrix like below:

 

q6.PNGq5.PNG


Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

Just in case that your data is in the shape that you've shown, it's pretty easy to transform it into the shape of the solution above: In the query editor, you select the non-months columns, rightclick your mouse and choose: "Unpivot other columns":

 

PBI_YTDWhereMonthsAreColumnHeadings.png

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @KSt,

 

From your description, it seems you are using the matrix to display the values, and the “Apr-16”,”May-16”,…. come from one column field, right?

 

Assume the sample data likes below:

 

q4.PNG

 

You can create a measure like this:

 

Cumulative = CALCULATE(SUM(Table1[Value]),FILTER(ALL('Table1'),'Table1'[Date]<=MAX('Table1'[Date])),VALUES(Table1[NL]),VALUES(Table1[CC]),VALUES(Table1[Name]),VALUES(Table1[Project]),VALUES(Table1[Dept]))

 

Then create a matrix like below:

 

q6.PNGq5.PNG


Best Regards,
Qiuyun Yu

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

Just in case that your data is in the shape that you've shown, it's pretty easy to transform it into the shape of the solution above: In the query editor, you select the non-months columns, rightclick your mouse and choose: "Unpivot other columns":

 

PBI_YTDWhereMonthsAreColumnHeadings.png

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

KSt
Frequent Visitor

Thank you ImkeF, unpivoting those columns was what needed to happen 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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