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
Syndicate_Admin
Administrator
Administrator

Calculation of Variations and % of Participation

Dear Forum, good morning.

I am having certain problems when creating a measure that calculates the variation between periods and Counterpart markets and the % of market share for that period.Tabla.PNG

What I seek to do is calculate in a single measure, the variation that exists between, for example, the MAT Aug 2023 of the market Rx Vs the MAT Aug 2022, as well as calculate the total sum that is in the MAT Aug 2023, that is, Rx + Otc.

Your help means a lot.

Best regards!

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

Hi  @Syndicate_Admin ,

 

Here are the steps you can follow:

1. In Power Query – Select [Moving Annual Total] – Duplicate Column.

vyangliumsft_0-1696213521056.png

2. Select [Copy Moving Annual Total] – Split column.

vyangliumsft_1-1696213541817.png

vyangliumsft_2-1696213541819.png

3. Create measure.

Measure1 =
var _today=TODAY()
var _currentyear=YEAR(_today)
var _lastmonth=FORMAT(EOMONTH(_today,-1),"mmm")
var _value1=
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())&&'Table'[Moving Annual Total - Copy.2]=_lastmonth&&'Table'[Market(E/OTC)]="Rx"),[Value])
var _value2=
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())-1&&'Table'[Moving Annual Total - Copy.2]=_lastmonth&&'Table'[Market(E/OTC)]="Rx"),[Value])
return
_value1 - _value2
Measure2 =
var _today=TODAY()
var _currentyear=YEAR(_today)
var _lastmonth=FORMAT(EOMONTH(_today,-1),"mmm")
return
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())&&'Table'[Moving Annual Total - Copy.2]=_lastmonth),[Value])

 

Best Regards,

Liu Yang

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

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Syndicate_Admin ,

 

Here are the steps you can follow:

1. In Power Query – Select [Moving Annual Total] – Duplicate Column.

vyangliumsft_0-1696213521056.png

2. Select [Copy Moving Annual Total] – Split column.

vyangliumsft_1-1696213541817.png

vyangliumsft_2-1696213541819.png

3. Create measure.

Measure1 =
var _today=TODAY()
var _currentyear=YEAR(_today)
var _lastmonth=FORMAT(EOMONTH(_today,-1),"mmm")
var _value1=
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())&&'Table'[Moving Annual Total - Copy.2]=_lastmonth&&'Table'[Market(E/OTC)]="Rx"),[Value])
var _value2=
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())-1&&'Table'[Moving Annual Total - Copy.2]=_lastmonth&&'Table'[Market(E/OTC)]="Rx"),[Value])
return
_value1 - _value2
Measure2 =
var _today=TODAY()
var _currentyear=YEAR(_today)
var _lastmonth=FORMAT(EOMONTH(_today,-1),"mmm")
return
SUMX(
    FILTER(ALL('Table'),
    'Table'[Moving Annual Total - Copy.3]=YEAR(TODAY())&&'Table'[Moving Annual Total - Copy.2]=_lastmonth),[Value])

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Syndicate_Admin , based on what I got, You can use Time intelligence with date table

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))


last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
Previous year Month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth(dateadd('Date'[Date],-11,MONTH)))

 

diff = [MTD Sales]-[last year MTD Sales]
diff % = divide([MTD Sales]-[last year MTD Sales],[last year MTD Sales])

 

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.