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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Yadidya
Regular Visitor

Need help with DAX

Hello !!!

I am pretty much new to Power BI. I am trying to build a Formula 1 visualization from this dataset:https://www.kaggle.com/datasets/rohanrao/formula-1-world-championship-1950-2020. I have created a measure to show who is the champion with the help of Chat GPT, to be honest. The measure is 

Champion = CALCULATE(FIRSTNONBLANK(drivers[surname],1), TOPN(1, SUMMARIZE(results, drivers[surname], races[year], "Total_Points", [Total_Points]), [Total_Points], DESC)). It shows the champion name and if we use the year as a filter, we can get the list of champions for every year (attachment). Now I want to visualize in a bar chart how many times a driver became a champion. Hamilton 7 times, Schumacher 7, so on ..
 
Kindly help
 
Pic1.png
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Yadidya 

 

@ToddChitt Thank you very much for your prompt reply.

 

I was checking the forum posts and found your post. May I ask if your problem has been solved? If not yet, I have an idea.

 

If the measure you provided outputs the desired result, then please try it:

 

Create a measure.

 

 
count champion = 
var currentChampion = [champion]
RETURN
CALCULATE(
    COUNTROWS('Table'), 
    FILTER(
        ALL('Table'), 
        'Table'[champion] = currentChampion
    )
)

 

Here is the result.

 

vnuocmsft_0-1714540874445.png

 

I've attached a simple demo.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Yadidya 

 

@ToddChitt Thank you very much for your prompt reply.

 

I was checking the forum posts and found your post. May I ask if your problem has been solved? If not yet, I have an idea.

 

If the measure you provided outputs the desired result, then please try it:

 

Create a measure.

 

 
count champion = 
var currentChampion = [champion]
RETURN
CALCULATE(
    COUNTROWS('Table'), 
    FILTER(
        ALL('Table'), 
        'Table'[champion] = currentChampion
    )
)

 

Here is the result.

 

vnuocmsft_0-1714540874445.png

 

I've attached a simple demo.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

ToddChitt
Super User
Super User

Can you just take some screen shots of actual data (not the model view) of the tables involved?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





@ToddChitt Thanks for the reply. I am attaching the screenshots of the tables.  

drivers_table.pngresults_table.pngraces_table.png

Yadidya
Regular Visitor

@ToddChitt my data source is from this link https://www.kaggle.com/datasets/rohanrao/formula-1-world-championship-1950-2020. The CHampion measure is Champion = CALCULATE(FIRSTNONBLANK(drivers[surname],1), TOPN(1SUMMARIZE(resultsdrivers[surname]races[year]"Total_Points"[Total_Points]), [Total_Points]DESC)).

 

Pic2.png

ToddChitt
Super User
Super User

You don't need DAX for that. Simply build a  COLUMN chart, add Driver Name (Champion) on the X axis and COUNT(Year) on the Y axis. Note that when you add [Year], because it is numeric, it may want to summarize it. You need to switch the aggregation from SUM to COUNT.

 




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





@ToddChitt When attempting to add the 'Champion' measure to the X-axis of a column chart, it is not being accepted, even when dragging and dropping. 

Maybe go back and ask Chat GPT what went wrong? 🙂

Can you show us an example of your source data BEFORE Chat GPT did anything to it?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.