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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
HamidBee
Power Participant
Power Participant

DAX measure containing conditional statement does not show total values

I am working with the following data:

 

Total MinutesZones
456A
324B
785C
787D
343E
677A
234B
546C
898D
995E


I have created two measures:

 

ZoneParkingTime (minutes) = SUM('Parking Data'[Total Minutes])

and:

Petrol Price (£) = 

IF(
SELECTEDVALUE('Parking Data'[Zones])="A",([ZoneParkingTime (minutes)]*2/60),
IF(
SELECTEDVALUE('Parking Data'[Zones])="B",([ZoneParkingTime (minutes)]*6/60),
IF(
SELECTEDVALUE('Parking Data'[Zones])="C",([ZoneParkingTime (minutes)]*6/60),
IF(
SELECTEDVALUE('Parking Data'[Zones])="D",([ZoneParkingTime (minutes)]*3/60),
IF(
SELECTEDVALUE('Parking Data'[Zones])="E",([ZoneParkingTime (minutes)]*2/60)
)
)
)
)
)

The measure, Petrol Price (£) does not seem to give a total. I obtain the following results:

Results.png

Does anyone have any idea as to why this may be happening?. I am attaching the file here if you would like to have a play around with it:

 

https://www.mediafire.com/file/rirkm73zvrnumxf/Conditional_Statement.pbix/file

 

Thank you,

1 ACCEPTED SOLUTION
davehus
Memorable Member
Memorable Member

Hi @HamidBee ,

 

Sorry deleted the first post as it wasn't giving totals. See below.

 

Petrol Price (£) = SUMX(VALUES('Parking Data'[Zones]),IF(FIRSTNONBLANK('Parking Data'[Zones],1)="A",DIVIDE([ZoneParkingTime (minutes)]*2.8,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="B",DIVIDE([ZoneParkingTime (minutes)]*6.1,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="C",DIVIDE([ZoneParkingTime (minutes)]*6.1,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="D",DIVIDE([ZoneParkingTime (minutes)]*3.05,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="E",DIVIDE([ZoneParkingTime (minutes)]*2.8,60)
))))))

View solution in original post

10 REPLIES 10
davehus
Memorable Member
Memorable Member

Hi @HamidBee ,

 

Sorry deleted the first post as it wasn't giving totals. See below.

 

Petrol Price (£) = SUMX(VALUES('Parking Data'[Zones]),IF(FIRSTNONBLANK('Parking Data'[Zones],1)="A",DIVIDE([ZoneParkingTime (minutes)]*2.8,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="B",DIVIDE([ZoneParkingTime (minutes)]*6.1,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="C",DIVIDE([ZoneParkingTime (minutes)]*6.1,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="D",DIVIDE([ZoneParkingTime (minutes)]*3.05,60),
IF(FIRSTNONBLANK('Parking Data'[Zones],1)="E",DIVIDE([ZoneParkingTime (minutes)]*2.8,60)
))))))

I'd kindly like to ask what the expression "1" in the equation refers to?

Nice. This DAX forumla works. I tried the one that you had deleted. So I was responding to that earlier. 

Thanks. I tried this but unfortunately it didn't work. 

 

Hi @HamidBee, The above is an updated version. I'd deleted the first one. 

Make it into a Column instead and drop SELECTEDVALUE from your code.

Petrol Price £ =

IF(
('Parking Data'[Zones])="A",([ZoneParkingTime (minutes)]*2/60),
IF(
('Parking Data'[Zones])="B",([ZoneParkingTime (minutes)]*6/60),
IF(
('Parking Data'[Zones])="C",([ZoneParkingTime (minutes)]*6/60),
IF(
('Parking Data'[Zones])="D",([ZoneParkingTime (minutes)]*3/60),
IF(
('Parking Data'[Zones])="E",([ZoneParkingTime (minutes)]*2/60)
)
)
)
)
)





Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

Errors.png

Unfortunately this one gave me an error.

Was that when making it as a measure or as a column? It'll give that error if you use that code as a measure, but if you create a column instead it should work.


Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

I believe this was what you were referring to:

 

Petrol_Price (£) = VAR Y= ADDCOLUMNS('Parking Data', "New Formula",
IF(('Parking Data'[Zones])="A",([ZoneParkingTime (minutes)]*2.8/60), 
IF(('Parking Data'[Zones])="B",([ZoneParkingTime (minutes)]*6.1/60),
IF(('Parking Data'[Zones])="C",([ZoneParkingTime (minutes)]*6.1/60),
IF(('Parking Data'[Zones])="D",([ZoneParkingTime (minutes)]*3.05/60),0)))))

RETURN SUMX(Y,[Petrol Price (£)])

 

I had created it as a measure. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors