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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
christianfcbmx
Post Patron
Post Patron

AVERAGE BETWEEN YES AND NO?

Hi community, good afternoon!!!

 

I have the following chalange that I cant resolve about bands assistance:

 

I need to obtain a result out of a column called (Assistance YES OR NO which have blanks too) of my excel table for example: 

 

If we consider 3 months and 3 bands if they assisted to rehearse 3 consecutive months they get a discount. meaning that if they have a "NO" any month of the three they won't get the discount. (When the column is "BLANK") we dont have to consider that as a "NO" I just don't need to consider blanks in my calculation.

 

CAN YOU GUYS SUGGEST ME A FORMULA DAX TO SOLVE THAT?

 

any advice would be so much appreciated!!!: (down below is how my table looks like)

 

ASSISTANCE TABLE RESUME 3 LAST MONTHS
MUSIC BANDSMONTHSASSISTANCE YES/NO MUSIC BANDSDISCOUNT (EXPECTED RESULT)
BAND1OctoberYES BAND1YES
BAND2October  BAND2YES
BAND3OctoberNO BAND3NO
BAND1NovemberYES   
BAND2NovemberYES   
BAND3NovemberYES   
BAND1DecemberYES   
BAND2DecemberYES   
BAND3DecemberYES   
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@christianfcbmx

 

To achieve your requirement, you may create a measure using DAX formlula below then drag MUSIC BANDS and measure to a table visual.

DISCOUNT (EXPECTED RESULT) = 
IF (
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            ALLEXCEPT ( Table1, Table1[MUSIC BANDS] ),
            Table1[MONTHS] IN { "December", "November", "October" }
                && (
                    Table1[ASSISTANCE YES/NO] = "YES"
                        || Table1[ASSISTANCE YES/NO] = BLANK ()
                )
        )
    )
        = CALCULATE (
            COUNTROWS ( Table1 ),
            FILTER (
                ALLEXCEPT ( Table1, Table1[MUSIC BANDS] ),
                Table1[MONTHS] IN { "December", "November", "October" }
            )
        ),
    "YES",
    "NO"
)

Capture.PNGCapture.PNG 

 

 

Regards,

Jimmy Tao

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@christianfcbmx

 

To achieve your requirement, you may create a measure using DAX formlula below then drag MUSIC BANDS and measure to a table visual.

DISCOUNT (EXPECTED RESULT) = 
IF (
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            ALLEXCEPT ( Table1, Table1[MUSIC BANDS] ),
            Table1[MONTHS] IN { "December", "November", "October" }
                && (
                    Table1[ASSISTANCE YES/NO] = "YES"
                        || Table1[ASSISTANCE YES/NO] = BLANK ()
                )
        )
    )
        = CALCULATE (
            COUNTROWS ( Table1 ),
            FILTER (
                ALLEXCEPT ( Table1, Table1[MUSIC BANDS] ),
                Table1[MONTHS] IN { "December", "November", "October" }
            )
        ),
    "YES",
    "NO"
)

Capture.PNGCapture.PNG 

 

 

Regards,

Jimmy Tao

LivioLanzo
Solution Sage
Solution Sage

Hello Christian, does it mean that blanks are always considered as 'YES'? What does the real data looks like, does it have all the data and you want to look at just the previous three months?

 


 


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


Proud to be a Datanaut!  

Hi, @LivioLanzo!...thats correct, the blanks would be considered always as a YES.

 

The data contain all data, meaning "more months" and I need to always consider the last 3 months.

 

Real data looks like this pic (little example)

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.