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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
HamidBee
Power Participant
Power Participant

How do I edit the DAX below so that the column doesn't return a total value?

I am working with the following DAX:


 

Petrol or Diesel = 
VAR A =
    ADDCOLUMNS (
        'Parking Data',
        "Petrol or Diesel",
            IF (
                [Petrol Price (£)] = SUM ( 'Data'[Amount] ),
                "Petrol",
                "Diesel"
            )
    )
RETURN
    MAXX ( A, [Petrol or Diesel] )

 

 

The issue with this DAX is that it gives me a total of either "Diesel" or "Petrol". Please see below:

Petrol or Disel.jpg

How do I stop the total from showing (for this column only)?.

1 ACCEPTED SOLUTION

Hi,

Try this measure

Petrol or Diesel = if(hasonevalue('Table'[ID]),if([Total]=1,"Petrol","Diesel"),BLANK())

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@HamidBee can you share one drive/google drive, I don't like to use any other website. Sorry 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I was honestly about to get around to it. Opened the thread and I saw that someone provided a solution. Thanks anyway. 

parry2k
Super User
Super User

@HamidBee can you post the raw data and what you are trying to achieve? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I can't share the exact file as it contains sensitive data but please find attached an example file I have created below:

https://www.mediafire.com/file/8j45jqb8uj41mzr/Example_File.pbix/file

 

You will see a visual of a matrix. The matrix has totals under each column. For the "Petrol or Diesel" column there is a total of "Diesel". What I'd like is for there to be no total to show for that column only. 

 

Thanks in advance.

Hi,

Try this measure

Petrol or Diesel = if(hasonevalue('Table'[ID]),if([Total]=1,"Petrol","Diesel"),BLANK())

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you, this worked beautifully. I have never used the HASONEVALUE function. I had a read through the Microsoft documenation but I didn't fully understand it. In the code you have written is HASONEVALUE used to iterate through all of the IDs to determine if there is a unique value and if there is it returns blank?. 

 

Thanks

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors