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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Tidying up Dax Measures in a single measure

I am currently trying to report on some data from a database and can get the results I need but in a piecemeal way using multiple Measures.

 

I would like to know if there is an easier way to present this in a single measure rather using multiple measures which is slowing my system down.

 

As an example if I want to look at some columns in a table by a (Name) (Days Present), (Hair Colour) (Height) and produce a score of 8 if the criteria I want is met and a score of 0 if it isnt I end up writing 3 measures to do this.

 

The Table is called PupilData

Assume the criteria is (Days Present)>=7 and <=10, (Hair Colour)= "Brown", (Height)=160  - Score 8 if Not Score 0

 

I split this down into chunks of data to get the end result so an example would be to write a measure

 

Measure 1 - Dayspresent between 7&10 TF = SELECTEDVALUE(Days Present)>=7 && SELECTEDVALUE(Days Present) <=10

This would then return a true or false so to convert it to a 1 or 0 then

Measure 2 - Dayspresent between 7 & 10 INT = INT([Dayspresent between 7&10 TF])

That would return a 1 or 0 for days beetween 7 and 10 range

Then to produce a result of 8 or 0

Measure 3 - Dayspresent Value 8 = [Dayspresent between 7 & 10 INT]*8

 

If I then wanted the same for (Hair Colour) & (Height) I would create the 3 measures for each and then use mathamatics to add together and get a result, the process being as follows;

 

1 - Determine the value if true or false

2 - Convert that true or false to an integer to get 1 or 0

3 - Multiply that integer by the score I required. (in this case to get 8 or 0)

 

Very long winded but it gets to the requred result by thinking primative binary

 

a one step solution to get the result of 8 or 0 would cut my measures down by a third if anyone could kindly assist.

 

Cheers

 

Dax Novice

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can write the DAX more similar to your written criteria than going through all of these steps.

Score =
VAR Days = SELECTEDVALUE ( PupilData[Days Present] )
VAR Hair = SELECTEDVALUE ( PupilData[Hair Color] )
VAR Hgt = SELECTEDVALUE ( PupilData[Height] )
RETURN
    IF ( Days >= 7 && Days <= 10 && Hair = "Brown" && Hgt = 160, 8, 0 )

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You can write the DAX more similar to your written criteria than going through all of these steps.

Score =
VAR Days = SELECTEDVALUE ( PupilData[Days Present] )
VAR Hair = SELECTEDVALUE ( PupilData[Hair Color] )
VAR Hgt = SELECTEDVALUE ( PupilData[Height] )
RETURN
    IF ( Days >= 7 && Days <= 10 && Hair = "Brown" && Hgt = 160, 8, 0 )
Anonymous
Not applicable

Cheers, thats great, did the trick and took a 10th of the effort & time !

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.