Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calulating against many different fields

I have a table called Trainer. It has the following integer fields tcd, tsp, tgoing, tcourse, thorse, t_val_rank,winpos,eventdate   So far I have the following measure Total Wins = CALCULATE( SUM(...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    I created a sample pbix file(see the attachment), please check if that is what you want.

    1. Unpivot the value type columns in Power Query Editor except [winpos] column

    = Table.Unpivot(#"Changed Type", {"tcd", "tsp", "tgoing", "tcourse", "thorse", "t_val_rank"}, "Attribute", "Value")

    2. Create a measure as below to get the sum of value

    Total Wins = 
    CALCULATE (
        SUM ( TrainerStats[Value] ),
        FILTER (
            'TrainerStats',
            TrainerStats[winpos] = 1
                && TrainerStats[Attribute]
                    IN ALLSELECTED ( 'TrainerStats'[Attribute] )
                        && 'TrainerStats'[Value] IN ALLSELECTED ( 'TrainerStats'[Value] )
        )
    )

     

    If the above one can't help you get the expected result, could you please provide some raw data in the table 'TrainerStats' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards