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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rajat96
New Member

Applying Filters on different hierarchy levels

Hello PBI Community, 

I am working on a problem statement that requires me to compare the sales varainces between two different periods. For example, I have to find the difference between the % of total sales for quarter 1 and % of total sales for May month end, to understand the difference in different categories of product. However,  data is defined in a maner wherein Quarter 1 can have only Jan, Feb and March.

Based on the selected month from the drop down, I want to calculate the above difference. However, I am unable to do the same when I have to subtract Quarter 1 results from that of May month end as they do not fall in the same hierarchies. 

@PowBi

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @rajat96 ,

 

I suggest you to create two Date tables and then create two inactive relationship between them to Fact table.

vrzhoumsft_0-1688461208542.png

Measure:

Sales % Period 1 = 
VAR _Period1 = TOTALYTD(SUM('Table'[Sales]),'Period 1'[Date],USERELATIONSHIP('Period 1'[Date],'Table'[Date]))
VAR _TotalYTD = TOTALYTD(SUM('Table'[Sales]),ALL('Period 1'[Date]),USERELATIONSHIP('Period 1'[Date],'Table'[Date]))
RETURN
DIVIDE(_Period1,_TotalYTD)
Sales % Period 2 = 
VAR _Period1 = TOTALYTD(SUM('Table'[Sales]),'Period 1'[Date],USERELATIONSHIP('Period 2'[Date],'Table'[Date]))
VAR _TotalYTD = TOTALYTD(SUM('Table'[Sales]),ALL('Period 2'[Date]),USERELATIONSHIP('Period 2'[Date],'Table'[Date]))
RETURN
DIVIDE(_Period1,_TotalYTD)
Diff = [Sales % Period 1] - [Sales % Period 2]

Result is as below.

 

vrzhoumsft_1-1688461254868.png

 

Best Regards,
Rico Zhou

 

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

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @rajat96 ,

 

I suggest you to create two Date tables and then create two inactive relationship between them to Fact table.

vrzhoumsft_0-1688461208542.png

Measure:

Sales % Period 1 = 
VAR _Period1 = TOTALYTD(SUM('Table'[Sales]),'Period 1'[Date],USERELATIONSHIP('Period 1'[Date],'Table'[Date]))
VAR _TotalYTD = TOTALYTD(SUM('Table'[Sales]),ALL('Period 1'[Date]),USERELATIONSHIP('Period 1'[Date],'Table'[Date]))
RETURN
DIVIDE(_Period1,_TotalYTD)
Sales % Period 2 = 
VAR _Period1 = TOTALYTD(SUM('Table'[Sales]),'Period 1'[Date],USERELATIONSHIP('Period 2'[Date],'Table'[Date]))
VAR _TotalYTD = TOTALYTD(SUM('Table'[Sales]),ALL('Period 2'[Date]),USERELATIONSHIP('Period 2'[Date],'Table'[Date]))
RETURN
DIVIDE(_Period1,_TotalYTD)
Diff = [Sales % Period 1] - [Sales % Period 2]

Result is as below.

 

vrzhoumsft_1-1688461254868.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.