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
SantosLuis
Regular Visitor

Using views or tables and unpivot data

New to Power BI... doing an online course but thus far didn't cover this specific work requirement:

 

Need to consume financial data from a SQL Server database view. View contains financial budgets and actuals for each financial year (FY), GL account and each row includes 12 financial periods (i.e. months) all in a single row (example below). 

 

Also in Australia FY's go from July to June so for FY 2021 period 1 is June 2020 and period 12 is June 2021.

 

lgr_accpst_yeract_p01act_p02act_p03act_p04 bgt_p01bgt_p02bgt_p03
10042021-241-872-908-2338.82(...)-899-1798-2697

 

I have two questions towards a better understanding of Power BI recommendations and best practices. 

  

1. is that OK to use a database view as it already includes GL account description, funding source description, etc OR should I use  source tables instead so that I can have separate lookup tables for filtering, drilling, etc.

 

2. All our financial tables include 12 financial year periods so for financial year 2021, actuals for period 1 are stored in field act_p01 (July 2020) and budget for period 12 is in field bgt_p12. For reporting purposes I think (?) I need to derive a period number (at present determined by the field name) and unpivot data so I can filters, present graphs, etc in a vertical fashion. I envisage data to be then consumed as per format below.

 

lgr_accpst_yercmt_balperiodactuals budget
1004202101-241300
1004202102-50100
1004202103-50006000

 

Any suggestions, guidance and pointers to relevant online information will be most appreciated.

 

Thank you

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SantosLuis , I feel like I have seen this database.

Steps

1. Unpivot the period columns - https://radacad.com/pivot-and-unpivot-with-power-bi
2. Split the column by _  . You will get like act P06  -https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

3. Combine/Concat year and period or remove p from the period(and convert to number)  and use [Year]*100 + [Priod] - https://docs.microsoft.com/en-us/powerquery-m/text-combine

https://docs.microsoft.com/en-us/powerquery-m/text-remove

 

Now create a separate table with year, period, and year period (combine)

Create an rank and use for period over period analysis

 

new column

Period Rank = RANKX(all('Period'),'Period'[year period],,ASC,Dense)

 

measure
This Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
Last Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

View solution in original post

3 REPLIES 3
v-xiaoyan-msft
Community Support
Community Support

Hi@SantosLuis

 

Has your problem been solved ? if so, please consider Accept a correct reply as the solution to help others find it.
 
Best regards,
Caitlyn Yan

 

SantosLuis
Regular Visitor

Amitchandak,

 

Thank you, very useful and complete answer.

 

Regards

amitchandak
Super User
Super User

@SantosLuis , I feel like I have seen this database.

Steps

1. Unpivot the period columns - https://radacad.com/pivot-and-unpivot-with-power-bi
2. Split the column by _  . You will get like act P06  -https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

3. Combine/Concat year and period or remove p from the period(and convert to number)  and use [Year]*100 + [Priod] - https://docs.microsoft.com/en-us/powerquery-m/text-combine

https://docs.microsoft.com/en-us/powerquery-m/text-remove

 

Now create a separate table with year, period, and year period (combine)

Create an rank and use for period over period analysis

 

new column

Period Rank = RANKX(all('Period'),'Period'[year period],,ASC,Dense)

 

measure
This Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
Last Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

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.