cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
andresloji
Helper I
Helper I

Virtual Table to classify Chanels

Hello!

I have a data base with the following columns (also attached in this link: DB PBI )

YearQuarterWeekCountryProduct GroupProduct Sub-GroupSalesQuantityChannelsStock

 

I need to classify the chanels in 2: Big chanels and Small chanels

 

Big Chanels sold more than 25K in the past 3 Quarters

Small Chanels sold less than 25K in the past 3 Quarter

 

I need to create a slicer to filter my report by Big Chanels or Small Chanels

 

How can I do it?

 

Thanks in advance!

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

Hi @andresloji ,

The following output is like your xlsx,but not roll up:

vluwangmsft_0-1638178700184.png

And if you need roll up,see the below:

vluwangmsft_1-1638178751599.png

 

Import data ,then create change many column form text to whole number ,then create the below column ,and measure:

sumsale = CALCULATE(SUM(DB1[Sales]),FILTER(ALL(DB1),DB1[Year]=MAX(DB1[Year])&&DB1[Quarter]=MAX(DB1[Quarter])&&DB1[Channels]=MAX(DB1[Channels])&&DB1[Stock]="Not Stock"))

column:

sumsale1 = 
CALCULATE (
    SUM ( DB1[Sales] ),
    FILTER (
        ALL ( DB1 ),
        DB1[Year] = EARLIER ( DB1[Year] )
            && DB1[Quarter] = EARLIER ( DB1[Quarter] )
            && DB1[Channels] = EARLIER ( DB1[Channels] )
            && DB1[Stock] = "Not Stock"
    )
)

measure:

Channel = 
IF (
    MAX ( DB1[sumsale1] ) >= 25000
        && CALCULATE (
            MAX ( DB1[sumsale1] ),
            FILTER (
                ALL ( DB1 ),
                DB1[Channels] = MAX ( DB1[Channels] )
                    && IF (
                        MAX ( DB1[Quarter] ) >= 2,
                        DB1[Quarter]
                            = MAX ( DB1[Quarter] ) - 1
                            && DB1[Year] = MAX ( DB1[Year] ),
                        DB1[Quarter] = 4
                            && DB1[Year]
                                = MAX ( DB1[Year] ) - 1
                    )
            )
        ) >= 25000
        && CALCULATE (
            MAX ( DB1[sumsale1] ),
            FILTER (
                ALL ( DB1 ),
                DB1[Channels] = MAX ( DB1[Channels] )
                    && IF (
                        MAX ( DB1[Quarter] ) >= 3,
                        DB1[Quarter]
                            = MAX ( DB1[Quarter] ) - 2
                            && DB1[Year] = MAX ( DB1[Year] ),
                        IF (
                            MAX ( DB1[Quarter] ) = 2,
                            DB1[Quarter] = 4
                                && DB1[Year]
                                    = MAX ( DB1[Year] ) - 1,
                            DB1[Quarter] = 3
                                && DB1[Year]
                                    = MAX ( DB1[Year] ) - 1
                        )
                    )
            )
        ) >= 25000,
    "Big Channel",
    "Small channel"
)

 

And you could download my pbix file if you need!

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @andresloji ,

The following output is like your xlsx,but not roll up:

vluwangmsft_0-1638178700184.png

And if you need roll up,see the below:

vluwangmsft_1-1638178751599.png

 

Import data ,then create change many column form text to whole number ,then create the below column ,and measure:

sumsale = CALCULATE(SUM(DB1[Sales]),FILTER(ALL(DB1),DB1[Year]=MAX(DB1[Year])&&DB1[Quarter]=MAX(DB1[Quarter])&&DB1[Channels]=MAX(DB1[Channels])&&DB1[Stock]="Not Stock"))

column:

sumsale1 = 
CALCULATE (
    SUM ( DB1[Sales] ),
    FILTER (
        ALL ( DB1 ),
        DB1[Year] = EARLIER ( DB1[Year] )
            && DB1[Quarter] = EARLIER ( DB1[Quarter] )
            && DB1[Channels] = EARLIER ( DB1[Channels] )
            && DB1[Stock] = "Not Stock"
    )
)

measure:

Channel = 
IF (
    MAX ( DB1[sumsale1] ) >= 25000
        && CALCULATE (
            MAX ( DB1[sumsale1] ),
            FILTER (
                ALL ( DB1 ),
                DB1[Channels] = MAX ( DB1[Channels] )
                    && IF (
                        MAX ( DB1[Quarter] ) >= 2,
                        DB1[Quarter]
                            = MAX ( DB1[Quarter] ) - 1
                            && DB1[Year] = MAX ( DB1[Year] ),
                        DB1[Quarter] = 4
                            && DB1[Year]
                                = MAX ( DB1[Year] ) - 1
                    )
            )
        ) >= 25000
        && CALCULATE (
            MAX ( DB1[sumsale1] ),
            FILTER (
                ALL ( DB1 ),
                DB1[Channels] = MAX ( DB1[Channels] )
                    && IF (
                        MAX ( DB1[Quarter] ) >= 3,
                        DB1[Quarter]
                            = MAX ( DB1[Quarter] ) - 2
                            && DB1[Year] = MAX ( DB1[Year] ),
                        IF (
                            MAX ( DB1[Quarter] ) = 2,
                            DB1[Quarter] = 4
                                && DB1[Year]
                                    = MAX ( DB1[Year] ) - 1,
                            DB1[Quarter] = 3
                                && DB1[Year]
                                    = MAX ( DB1[Year] ) - 1
                        )
                    )
            )
        ) >= 25000,
    "Big Channel",
    "Small channel"
)

 

And you could download my pbix file if you need!

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

That is genius, thank you very much!

andresloji
Helper I
Helper I

Hello @VahidDM , I don't understand what the expected output is, can you explain me how to get it?

VahidDM
Super User
Super User

Hi @andresloji 

 

Can you post the Expected output from your sample data?


Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors