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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

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(TrainerStats[winpos]),FILTER('TrainerStats',TrainerStats[winpos]=1 && TrainerStats[t_val_rank]=1))

It works. It sums all the occasions when [winpos]= and [t_val_rank]=1 .

 

But I would like a measure that would calculate the sum of winpos for any given value of any of the above fields ie so [winpos]= 1 && [tcd] =1 or [tsp] =1 etc.

At this stage of my learning DAX I would be happy with achieving that, but ultimately I would like to calcuate any of the above fields against [winpos] but instead of being restricted to a value of 1 for [tcd] I would like to show where [tcd] = any value in the tdc field ie 2, 3 or 4.

This is day 3 of my Dax frustration, so any help would be appreciated. Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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")

vyiruanmsft_1-1681702642654.png

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] )
    )
)

vyiruanmsft_0-1681702557708.png

 

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

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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")

vyiruanmsft_1-1681702642654.png

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] )
    )
)

vyiruanmsft_0-1681702557708.png

 

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

 

Anonymous
Not applicable

Let me first apologise for not providing sample data, and then to thank you for time and effort. It's much appreciated, and as well as answering my initial question has helped enourmously in my understanding of power bi. Thank you again.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.