Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I am new to Dax and I need some help in getting an optimized way to create these measures. When I use these measures it takes a longer time to get the result
First measure=CALCULATE(
DISTINCTCOUNT(factInspectionViolation[InspectionKey]),
FILTER( 'dimInspection', dimInspection[InspectionLevelNumber] IN {3,2,1} )
)
Second Measure =
CALCULATE(
DISTINCTCOUNT(factInspectionViolation[InspectionKey]),
FILTER ( factInspectionViolation, [IsOutOfService] = "Y" ),
FILTER( dimViolation, [BASIC] IN { "Driver Fitness", "Hours of Service Compliance", "Controlled Substances / Alcohol" }
))
Third Measure=DIVIDE([SecondMeasure],[First Measuer])
Solved! Go to Solution.
See if it help to filter columns rather than tables.
DIVIDE (
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
FILTER (
VALUES ( 'dimInspection'[InspectionLevelNumber] ),
dimInspection[InspectionLevelNumber] IN { 3, 2, 1 }
)
),
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
FILTER (
VALUES ( factInspectionViolation[IsOutOfService] ),
factInspectionViolation[IsOutOfService] = "Y"
),
FILTER (
VALUES ( dimViolation[BASIC] ),
dimViolation[BASIC]
IN {
"Driver Fitness",
"Hours of Service Compliance",
"Controlled Substances / Alcohol"
}
)
)
)
It's a bit cleaner-looking like this:
DIVIDE (
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
KEEPFILTERS ( dimInspection[InspectionLevelNumber] IN { 3, 2, 1 } )
),
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
KEEPFILTERS ( factInspectionViolation[IsOutOfService] = "Y" ),
KEEPFILTERS ( dimViolation[BASIC]
IN {
"Driver Fitness",
"Hours of Service Compliance",
"Controlled Substances / Alcohol"
} )
)
)
See if it help to filter columns rather than tables.
DIVIDE (
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
FILTER (
VALUES ( 'dimInspection'[InspectionLevelNumber] ),
dimInspection[InspectionLevelNumber] IN { 3, 2, 1 }
)
),
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
FILTER (
VALUES ( factInspectionViolation[IsOutOfService] ),
factInspectionViolation[IsOutOfService] = "Y"
),
FILTER (
VALUES ( dimViolation[BASIC] ),
dimViolation[BASIC]
IN {
"Driver Fitness",
"Hours of Service Compliance",
"Controlled Substances / Alcohol"
}
)
)
)
It's a bit cleaner-looking like this:
DIVIDE (
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
KEEPFILTERS ( dimInspection[InspectionLevelNumber] IN { 3, 2, 1 } )
),
CALCULATE (
DISTINCTCOUNT ( factInspectionViolation[InspectionKey] ),
KEEPFILTERS ( factInspectionViolation[IsOutOfService] = "Y" ),
KEEPFILTERS ( dimViolation[BASIC]
IN {
"Driver Fitness",
"Hours of Service Compliance",
"Controlled Substances / Alcohol"
} )
)
)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
71 | |
70 | |
43 | |
31 | |
26 |
User | Count |
---|---|
89 | |
49 | |
44 | |
38 | |
37 |