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
Jaxon
Frequent Visitor

DAX Code | IF statements to help dynamically calculate a score

Edited to try an accomodate the suggestion I asked this wrong.... I'm trying. Hope this helped?

 

First - Forgive me if there is a better way to say this for you DAX pro's...I am looking for guidance if this can be done and if so - what conditional statement I could/should use:

 

3 Data Sources: Report_One, Report_Two, Report_Three

Each Looking Fairly Similar as this example:

 

Data_Example.jpg

We calculate Scores on each like this in a measures table where we keep all measures:

Note Score_One, Score_Two, Score_Three comes from a different data source. (Can't be merged due to other data needs inside)

Score_One =
DIVIDE (
    SUM ( Report_One[Yes] ),
    ( SUM ( Report_One[Yes] ) + SUM ( Report_One[No] ) )
)


Score_Two =
DIVIDE (
    SUM ( Report_Two[Yes] ),
    ( SUM ( Report_Two[Yes] ) + SUM ( Report_Two[No] ) )
)


Score_Three =
DIVIDE (
    SUM ( Report_Three[Yes] ),
    ( SUM ( Report_Three[Yes] ) + SUM ( Report_Three[No] ) )
)

 

 

Then we have a measure to calculate the overall score of the 3 reports such as:

OVERALL SCORE = 
 (
    CALCULATE (
        ( 'A1_Measures Table'[Score_One] * ( .33 )
            + ( ( 'A1_Measures Table'[Score_Two] ) * ( .33 )
            + ( 'A1_Measures Table'[Score_Three] ) * ( .33 ) ) )
    )
)

 

 

Business Problem

Sometimes on 1,2 or all 3 data sources we may not have data for an agent. (see example, Betty Rubble)

In this case I do not want to calculate the same way or it brings down the score unfairly.

So I would like to then adjust to accomodate those scenarios.

 

I assume I need and IF statement of some sort to adjust that says If No Data for a person in Report One, Two, or Three then Calculate like x,y,z...no data in all 3 can show (blank)

 

If no data for a paticular person in a report then calculate the Overall Score on the remaining two both scores at  .5, If no data for a particular person in two reports then calculate the Overall Score on the remaining report score at  1.0

 

Can this be done?

Best Way To Accomplish?

3 REPLIES 3
Jaxon
Frequent Visitor

Updated for clarity and to show code and formulas used to date.

Greg_Deckler
Super User
Super User

So, yes, it can be done by using something like COUNTROWS, etc. but no clue as to how to give you an answer with what you have presented.

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg. I'll see what I can do to help.

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.