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
Anonymous
Not applicable

Get Market Share from previous period

Hi, I have a pivot table with my products(columns) and some periods(rows), its market share for this month and I want another column with market share(values) but from same period of last year. I tried many things but no way.

 

My market share function is:

MS = [Period Selected]/CALCULATE([Period Selected],ALLSELECTED('m_product (2)'))*100
 
and I tried another DAX where THIS IS FAILING
MS LY = [Previous Period Selected]/CALCULATE([Previous Period Selected],ALLSELECTED('m_product (2)'))*100
 
another formulas:
Period Selected = SWITCH(TRUE(),
VALUES(m_period[Period])="MTH",[MTH],
VALUES(m_period[Period])="QRT",[QRT],
VALUES(m_period[Period])="YTD",[YTD],
VALUES(m_period[Period])="MAT",[MAT],
BLANK()
)
 
Thanks!!
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check my example attached.

Use "Year" column from Dates table not financials table in my example.

YTD.gif

 

Best Regards,

Icey

 

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

5 REPLIES 5
sirlanceohlott
Advocate III
Advocate III

I'll second @Icey's solution. This would be the easiest way to get to your required goal of showing the previous period market share. 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about this?

Create a Dates table and create relationship between your fact table and Dates table. Then, create [MS LY] measure like so:

MS LY =
CALCULATE (
    [MS],
    FILTER ( ALL ( Dates ), Dates[Year] = MAX ( Dates[Year] ) - 1 ),
    SAMEPERIODLASTYEAR ( Dates[Date] )
)

 

If this does not work, please share me some sample data for test.

 

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Hi @Icey ,

 

I created the 'Dates' table.

hernannor_0-1593174430898.png

 

This is what I want to see:

hernannor_1-1593174567885.png

 

 


And this are my formulas:

 

MS = [Period Selected]/CALCULATE([Period Selected],ALLSELECTED('m_product_ims (2)'))*100
 
MS LY = CALCULATE([MS],FILTER(ALL('Date'),'Date'[Year]=MAX('Date'[Year])-1),SAMEPERIODLASTYEAR('Date'[Date]))
 
MTH = if(SELECTEDVALUE(m_period[PeriodValue])=1 || ISBLANK(SELECTEDVALUE(m_period[PeriodValue])),
CALCULATE(SUM(FFFT_ARG_DDD_066E_202004[Valor]),DATESINPERIOD(m_mes[Period].[Date],LASTDATE(m_mes[Period]),-1,MONTH)))
 
MTH LY = CALCULATE([MTH],PARALLELPERIOD(m_mes[Period].[Date],-20,MONTH))
 
Period Selected = SWITCH(TRUE(),
VALUES(m_period[Period])="MTH",[MTH],
VALUES(m_period[Period])="QRT",[QRT],
VALUES(m_period[Period])="YTD",[YTD],
VALUES(m_period[Period])="MAT",[MAT],
BLANK())
 
Thanks!
 
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check my example attached.

Use "Year" column from Dates table not financials table in my example.

YTD.gif

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Thanks @Icey , that works!

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.