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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
mc_gadhzalova
Regular Visitor

NUMERIC DISTRIBUTION - MEASURE ISSUE

Hi All,

 

I have been struggling to create a measure to calculate numeric distribution. 
I need measure/s that calculate if a brand is avaliable in a store and then compared to the total number stores. 

My data is structured as it follows:

 

COUNTRYMONTHSTOREBRANDITEMEXISTS
BG1XENERGY DRINKCLASSIC FLAVOUR1
BG1XENERGY DRINKAPPLE FLAVOUR

0

BG1XCOFFEELATTE0
BG1YENERGY DRINKCLASSIC FLAVOUR0
BG1YENERGY DRINKAPPLE FLAVOUR0
BG1YCOFFEELATTE1
BG2XENERGY DRINKCLASSIC FLAVOUR1
BG2XENERGY DRINKAPPLE FLAVOUR1
BG2XCOFFEELATTE1
BG2YENERGY DRINKCLASSIC FLAVOUR0
BG2YENERGY DRINKAPPLE FLAVOUR0
BG2YCOFFEELATTE0

 

The logic is if there is atlest 1 item from each brand that exists in store, that there is brand distribution.

And my desired outcome logic is here:

COUNTRYMONTHSTOREBRANDBRAND DISTRIBUTION
BG1XENERGY DRINK1
BG1XCOFFEE0
BG1YENERGY DRINK0
BG1YCOFFEE1
BG2XENERGY DRINK1
BG2XCOFFEE1
BG2YENERGY DRINK0
BG2YCOFFEE0

 

I managed to reach this result with the use of the formula SUMMARIZE, but i couldn't move forward from this result to reach my desired calculation.
Also, my dataset is very large and copying the whole data and grouping in it Power Query isn't an option.

 

Thank you very much in advance!

Michaela

 

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

Hi @mc_gadhzalova ,

You can create a measure as below to get it, please find the details in the attachment.

BRAND DISTRIBUTION = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[COUNTRY],
        'Table'[MONTH],
        'Table'[STORE],
        'Table'[BRAND],
        "@count",
            CALCULATE (
                COUNT ( 'Table'[COUNTRY] )  , 
             FILTER (
                    'Table',
                    'Table'[COUNTRY] = EARLIER ( 'Table'[COUNTRY] )
                        && 'Table'[MONTH] = EARLIER ( 'Table'[MONTH] )
                        && 'Table'[STORE] = EARLIER ( 'Table'[STORE] )
                        && 'Table'[BRAND] = EARLIER ( 'Table'[BRAND] )
                        && 'Table'[EXISTS] = 1
                )
            )
    )
VAR _count =
    COUNTX ( _tab, [@count] )
RETURN
    IF ( _count > 0, 1, 0 )

vyiruanmsft_0-1701761756813.png

Best Regards

Community Support Team _ Rena
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-yiruan-msft
Community Support
Community Support

Hi @mc_gadhzalova ,

You can create a measure as below to get it, please find the details in the attachment.

BRAND DISTRIBUTION = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[COUNTRY],
        'Table'[MONTH],
        'Table'[STORE],
        'Table'[BRAND],
        "@count",
            CALCULATE (
                COUNT ( 'Table'[COUNTRY] )  , 
             FILTER (
                    'Table',
                    'Table'[COUNTRY] = EARLIER ( 'Table'[COUNTRY] )
                        && 'Table'[MONTH] = EARLIER ( 'Table'[MONTH] )
                        && 'Table'[STORE] = EARLIER ( 'Table'[STORE] )
                        && 'Table'[BRAND] = EARLIER ( 'Table'[BRAND] )
                        && 'Table'[EXISTS] = 1
                )
            )
    )
VAR _count =
    COUNTX ( _tab, [@count] )
RETURN
    IF ( _count > 0, 1, 0 )

vyiruanmsft_0-1701761756813.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbendlin
Super User
Super User

Why does it have to be a measure? Can it be influenced by filters?

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors