Categories: DAX
Tags:

These questions are made for the Dataset that was explored in Part 1 of this tutorial: Get Here

1. Total Fine Collected on Weekends

Question: Calculate the total fine amount collected on Saturdays and Sundays.

DAX (measure):

Total Weekend Fine = 
CALCULATE(
SUM(city_traffic_violation[Fine Amount]),
city_traffic_violation[Day of Week] IN {"Saturday", "Sunday"}
)

Explanation:
Uses CALCULATE to filter only weekend days, then sums the Fine Amount.

📌 Type: Measure


2. Average Fine Amount for Repeat Offenders (>0)

Question: Find the average fine amount where Repeat Offenders Count is greater than zero.

DAX (measure):

Avg Fine Repeat Offenders = 
CALCULATE(
AVERAGE(city_traffic_violation[Fine Amount]),
city_traffic_violation[Repeat Offenders Count] > 0
)

Explanation:
Focuses only on rows with repeat offenders, then takes the average fine.

📌 Type: Measure


3. Count of Violations per Vehicle Type

Question: For each vehicle type, count how many violations happened.

DAX (measure):

Violation Count = COUNTROWS(city_traffic_violation)

Alternate way of answering the question
Violation Count by Vehicle Type =
SUMMARIZE(
city_traffic_violation, city_traffic_violation[Vehicle Type],
"Violation Count", COUNTROWS(city_traffic_violation))

Explanation:
In a visual, add Vehicle Type to rows and this measure to values; it counts violations per vehicle type.

📌 Type: Measure


4. Percentage of Total Fine from Drunk Driving

Question: What percentage of the total fine amount is contributed by Drunk Driving violations?

DAX (measure):

Drunk Driving Fine % = 
DIVIDE(
CALCULATE(
SUM(city_traffic_violation[Fine Amount]),
city_traffic_violation[Violation Type] = "Drunk Driving"
),
SUM(city_traffic_violation[Fine Amount]),
0
)

Explanation:
Divides total fine for drunk driving by total fine overall.

📌 Type: Measure


5. Peak Violation Hour

Question: Create a calculated column to extract the hour number from Violation Time.

DAX (calculated column):

Violation Hour = 
VALUE(LEFT(city_traffic_violation[Violation Time], 2))

Explanation:
Takes first two characters of “HH:00” time and converts to a number.

📌 Type: Calculated column

#Measure
Peak Violation Hour = 
TOPN(
    1,
    SUMMARIZE(
        city_traffic_violation,
        city_traffic_violation[Violation Hour],
        "Violation Count", COUNTROWS(city_traffic_violation)
    ),
    [Violation Count], DESC
)

6. Total Fine by Zone and Violation Type

Question: Create a measure to show the total fine grouped by both Location Zone and Violation Type.

DAX (measure):

Total Fine by Zone & Type = SUM(city_traffic_violation[Fine Amount])

Explanation:
Simple sum measure; when used with Zone & Violation Type in a matrix, it will break down by both.

📌 Type: Measure


7. Highest Fine Amount Issued

Question: Find the highest single fine issued.

DAX (measure):

Max Fine Issued = MAX(city_traffic_violation[Fine Amount])

Explanation:
Returns the maximum value in Fine Amount.

📌 Type: Measure


8. Number of Violations with Fine > 500

Question: Count how many violations had fine amounts greater than 500.

DAX (measure):

High Fine Count = 
CALCULATE(
COUNTROWS(city_traffic_violation),
city_traffic_violation[Fine Amount] > 500
)

Explanation:
Filters rows with fine > 500, then counts them.

📌 Type: Measure


9. Average Number of Offenders per Violation Type

Question: Create a measure to calculate average number of offenders, and use it broken down by Violation Type.

DAX (measure):

Avg Offenders = AVERAGE(city_traffic_violation[Number of Offenders])

Explanation:
Shows the average when plotted against Violation Type.

📌 Type: Measure


10. Identify Repeat Offense Violations

Question: Create a calculated column flagging if a violation involved repeat offenders (Yes/No).

DAX (calculated column):

Is Repeat Offense = 
IF(city_traffic_violation[Repeat Offenders Count] > 0, "Yes", "No")

Explanation:
Helps you segment data into repeat vs first-time offenses.

📌 Type: Calculated column


Summary Table:

#QuestionType
1Total fine on weekendsMeasure
2Average fine for repeat offendersMeasure
3Count of violations per vehicle typeMeasure
4% fine from drunk drivingMeasure
5Extract violation hourCalculated column
6Total fine by zone & typeMeasure
7Highest fine issuedMeasure
8Number of violations with fine > 500Measure
9Average number of offendersMeasure
10Flag repeat offense violationsCalculated column