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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
akb989
New Member

Calculate a distribution with a measure

Hi everyone,

as per the title we want to calculate a distribution of planned sales per calendar week. Here is a simplified version of the table called ‘data’:

akb989_0-1704807328568.png

 

We have different product groups and within each group there are different products with a product ID. Each product is sold for a certain amount of time indicated by the start and end date column. For the sale period we have an estimated number of sales which can be broken down into sales per week.
The goal is to calculate the sum of the sales according to the calendar week of each product but summarized by the product group like so:

akb989_1-1704807328570.png

 



So for example in product group B none of the product are sold in calendar week 31 and 32 of 2023, and for the following calendar weeks only the product B8 is sold. So therefor in the matrix visual the sales per calendar week of only product B8 is shown.

How can we achieve this with a measure?

Thanks in advance!


1 ACCEPTED SOLUTION

Hi Ada, 
thank you for your response! Unfortunately it wasn't quite the outcome I wanted but I solved it in a differnet way by adding new columns to the data table for each calendar week and summing them with a measure. 😊
 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @akb989 ,

 

Based on the information you provided, you can follow these steps:

1.Add new table.

Table 2 = VALUES(data[Column])

 

2.Add new measure.

Measure =

VAR _a =

    CALCULATE (

        MAX ( 'data'[Sales per Week] ),

        FILTER (

            'data',

            [Product Group] = "A"

                && [Column] = SELECTEDVALUE ( 'Table 2'[Column] )

        )

    )

VAR _b =

    CALCULATE (

        MAX ( 'data'[Sales per Week] ),

        FILTER (

            'data',

            [Product Group] = "B"

                && [Column] = SELECTEDVALUE ( 'Table 2'[Column] )

        )

    )



VAR result =

    CALCULATE (

        MAX ( 'data'[Sales per Week] ),

        FILTER (

            ALLSELECTED ( 'data' ),

            'data'[Product Group]

                IN VALUES ( 'data'[Product Group] )

                    && 'data'[Column] IN VALUES ( 'Table 2'[Column] )

        )

    )

VAR _answer_ =

    IF ( result <> BLANK (), result, 0 )

RETURN

    IF ( ISINSCOPE ( 'data'[Product Group] ), _answer_, _b - _a )

 

Final output:

vyifanwmsft_0-1704878028307.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

Hi Ada, 
thank you for your response! Unfortunately it wasn't quite the outcome I wanted but I solved it in a differnet way by adding new columns to the data table for each calendar week and summing them with a measure. 😊
 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.