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
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
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.