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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
curiouspbix0
Helper IV
Helper IV

Dax Aggregation Issue

 

Hello Daxers,

 

Running into an aggregation here, first table shows raw data, second table is the dax measure which computes correctly when Status column is not used in the table.


Actual is skewed when Status is added to the table, where did this go wrong ?

 

Raw Data

VehicleStatusVehicle Count
BikesRunning10
BikesActive20
BikesOOO8
CarsRunning10
CarsActive23
CarsOOO11
BoatsRunning100
BoatsActive30
BoatsOOO9
OtherRunning2

Actual = COUNTROWS(DISTINCT(TableVehicle[VehicleID]))
,FILTER(ALL(TableVehicle[Status])
,TableVehicle[VehicleStatus]="Running"
|| TableVehicle[VehicleStatus]="Active")
)

Raw Data with DAX

VehicleActual 
Bikes30
Cars33
Boats130
Other2

 

Actual Result Table - Incorrect

VehicleStatusActual
BikesRunning30
BikesActive30
BikesOOO30
CarsRunning33
CarsActive33
CarsOOO33
BoatsRunning130
BoatsActive130
BoatsOOO130
OtherRunning2

 

What DAX for field Status would result in the below table.

 

Expected Result Table - Correct

VehicleStatus Actual
BikesRunning10
BikesActive20
CarsRunning10
CarsActive23
BoatsRunning100
BoatsActive30
OtherRunning2

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @curiouspbix0 ,

You can create a measure as below:

Actual =
CALCULATE (
    SUM ( 'TableVehicle'[Vehicle Count] ),
    FILTER ( 'TableVehicle', 'TableVehicle'[Status] IN { "Running", "Active" } )
)

yingyinr_0-1623832254783.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @curiouspbix0 ,

You can create a measure as below:

Actual =
CALCULATE (
    SUM ( 'TableVehicle'[Vehicle Count] ),
    FILTER ( 'TableVehicle', 'TableVehicle'[Status] IN { "Running", "Active" } )
)

yingyinr_0-1623832254783.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Singaravelu_R
Resolver III
Resolver III

In modeling click Net Table (write a dax expression to create new table) and write summarize DAX as per blow screenshot,

 

Singaravelu_R_0-1623669685026.png

 

amitchandak
Super User
Super User

@curiouspbix0 , remove all and try

 

Actual = COUNTROWS(DISTINCT(TableVehicle[VehicleID]))
,FILTER((TableVehicle)
,TableVehicle[VehicleStatus] in{"Running","Active"})
)

 

or

with allselected

 

Actual = COUNTROWS(DISTINCT(TableVehicle[VehicleID]))
,FILTER(allselected(TableVehicle)
,TableVehicle[VehicleStatus] in{"Running","Active"})
)

ALLSELECTED did not work and cannot remove ALL together on Filter condition. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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