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
p_kaushal
Frequent Visitor

create %share measure with repeated column value

Sample of my data]-The Total Base actually comes from a small table with year weekno and total base column which I create a relationship on year week no

 

yearweeknoregionFormatSales TYSales LYTotal Base
201652AsiaOnline76468063916
201652USStore85679563916
201652AsiaStore60384263916
201652UKOnline89466263916
201701AsiaOnline92584589125
201701USStore83777689125
201701AustraliaOnline84567589125
201701UKStore79379989125
201702AustraliaStore65967898456
201702UKOnline98159298456
201702AsiaStore51452098456
201702USOnline64896498456

 

 

The measure I want to calculate is %Share(of base)=(Sales TY-Sales LY)/Total Base

If I use a measure in PowerBI for this it would look like
%Share= (SUM('Table'[SalesTY])-sum('Table'[SalesLY]))/min('Table'[Total Base])

Even if I use max it wouldn't be different at week no levels
%Share= (SUM('Table'[SalesTY])-sum('Table'[SalesLY]))/max('Table'[Total Base])

It would look like the below table which would be same for min or max in the denominator since it would take only value to divide as it should

 

 

yearweeknoSales TYSales LY%Share
201652311729790.22%
201701340030950.34%
201702280227540.05%

 

 


The problem arises when you use a 'card' or only one week-it takes the total row and the data looks like this

 

201702280227540.0%
Total280227540.1%

 

 

This (0.1% i.e incorrect) takes the min base of the entire column when it should have taken only 201702

There is no way I can change that in card (as in donot show totals or something)

The problem might arise again if the slicer has only one week no and region level %share is calculated.

How do I arrive at a formula that shall help me get the corresponding denominator to divide in the %share calculation as min max donot work.

I have some pages with weekly line charts and %share as well as pages where it is just a week slicer with region %share
How do I make sure the formula works universally?

1 ACCEPTED SOLUTION

Sorry for the late reply!

 

I was able to solve the issue.The issue was not related to the formulas but it was related to the data connections and relationships between my tables which I had made between tables which was duplicating the dimension metric and hence max(base) was changing.

 

Thanks for looking into it though.Much appreciated.

View solution in original post

4 REPLIES 4
v-ljerr-msft
Employee
Employee

Hi @p_kaushal,

 

According to your description above, I have tested it with your sample data and the formulas. I am not sure I can reproduce your issue. It seems to work all fine for me.

%Share = 
 ( SUM ( 'Table1'[Sales TY] ) - SUM ( 'Table1'[Sales LY] ) )
    / MAX ( 'Table2'[Total Base] )

issue1.PNG

Here is the sample pbix file for your reference.Smiley Happy

 

Regards

Thanks for having a look.Yes, that's how it should work.Somehow the total row % share doesn't show correct values in my Power BI.

 

It's a weird error !data03.pngdata04.png

 

Hi @p_kaushal,

 

Yes, a little weird. Could you share a sample pbix file which can reproduce the issue? So that I can help further investigate on this issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.Smiley Happy

 

Regards

Sorry for the late reply!

 

I was able to solve the issue.The issue was not related to the formulas but it was related to the data connections and relationships between my tables which I had made between tables which was duplicating the dimension metric and hence max(base) was changing.

 

Thanks for looking into it though.Much appreciated.

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.