cancel
Showing results for 
Search instead for 
Did you mean: 
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
yingyinr
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
yingyinr
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"})
)



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

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

 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors