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

Calculating Share of Sales by Owner in Power BI with Changing Ownership Percentages

I am working on a sales analysis report where I have two tables: "Ownership" and "Sales." The "Ownership" table contains information about the percentage ownership of products by different owners, while the "Sales" table contains details about the sales transactions.

The "Ownership" table has the following columns: product, owner, financial year (fy), financial quarter (fq), and percentage. Here's a sample:

product owner fy fq percentage

xdattu24q150
xdattu24q270
xsan24q150
xsan24q230
ydattu24q130
ydattu24q270
ysan24q170
ysan24q230

The "Sales" table contains columns for date, product, and sales amount. Here's a sample:

date product sales

03-04-2023x10
04-04-2023y20
05-04-2023x30
06-04-2023y40
07-04-2023x50
08-04-2023y60
.........

Our financial cycle starts on April 1st and ends on March 31st. Each quarter consists of three consecutive months. For example, financial quarter 1 (fq1) includes April, May, and June.

I need to create a report where users can filter sales based on a specific date range. For instance, if a user selects a date range from 10/4/23 to 9/7/23, the sales should be filtered accordingly. Here's an example of the filtered sales data:

date product sales

10-04-2023y80
03-05-2023x90
04-05-2023y100
05-05-2023x110
06-05-2023y120
07-05-2023x130
.........

Now, I want to create a table visualization in Power BI to show the share of sales by owner based on the changing ownership percentages for the selected date range. The desired output should be as follows:

Owner Total Sales

dattu815
sanket615

I have attempted to calculate this using DAX measures, but I'm facing challenges in incorporating the changing ownership percentages for daterange.

@amitchandak please help

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

Hi @Anonymous ,

 

Please try:

Total Sales =
SUMX (
    'Ownership',
    [percentage] * 0.01
        * SUMX (
            FILTER (
                'Sales',
                [date]
                    >= IF (
                        VALUE ( RIGHT ( [fq], 1 ) ) <= 3,
                        DATE ( 2000 + [fy] - 1, VALUE ( RIGHT ( [fq], 1 ) ) * 3 + 1, 1 ),
                        DATE ( 2000 + [fy], 1, 1 )
                    )
                    && [date]
                        <= IF (
                            VALUE ( RIGHT ( [fq], 1 ) ) <= 3,
                            EOMONTH ( DATE ( 2000 + [fy] - 1, VALUE ( RIGHT ( [fq], 1 ) ) * 3 + 3, 1 ), 0 ),
                            DATE ( 2000 + [fy], 3, 31 )
                        )
                    && [product] = EARLIER ( Ownership[product] )
            ),
            [sales]
        )
)

Output:

vjianbolimsft_0-1689572632197.png

Best Regards,

Jianbo Li

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-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try:

Total Sales =
SUMX (
    'Ownership',
    [percentage] * 0.01
        * SUMX (
            FILTER (
                'Sales',
                [date]
                    >= IF (
                        VALUE ( RIGHT ( [fq], 1 ) ) <= 3,
                        DATE ( 2000 + [fy] - 1, VALUE ( RIGHT ( [fq], 1 ) ) * 3 + 1, 1 ),
                        DATE ( 2000 + [fy], 1, 1 )
                    )
                    && [date]
                        <= IF (
                            VALUE ( RIGHT ( [fq], 1 ) ) <= 3,
                            EOMONTH ( DATE ( 2000 + [fy] - 1, VALUE ( RIGHT ( [fq], 1 ) ) * 3 + 3, 1 ), 0 ),
                            DATE ( 2000 + [fy], 3, 31 )
                        )
                    && [product] = EARLIER ( Ownership[product] )
            ),
            [sales]
        )
)

Output:

vjianbolimsft_0-1689572632197.png

Best Regards,

Jianbo Li

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

tamerj1
Super User
Super User

Hi @Anonymous 

please try

AcumuladoAnterior =
CALCULATE (
Con_DetalleRC_ALL[Debe-Haber],
FILTER ( ALL ( Fechas ), Fechas[Fecha] <= MAX ( Fechas[Fecha] ) )
)

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.

Top Solution Authors