Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
Solved! Go to Solution.
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
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
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.