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

count value with filter

Hello, 

 

i have a data table with the 3 colums and i hope to get the last one:

Identification numbertravel dateReservation classTYPE
HAZERTY11/01/2019BI1st class
HAZERTY15/02/2019BI1st class
TYOPJRV12/03/2019BIMIX
TYOPJRV13/03/2019BZMIX

 

i have every time 2 lines for each Iden. number, for the earlier date of the identification number i have always BI but for the return (the later date of the identification class) i can find BI or BZ. if i have 2 times BI for the same identification number i want to call it 1st class and if i have another value for the return i want to call it mix

 

i am looking to get the colonne TYPE but i just can't find the way after spending few hours with this. 

I tried a :

CALCULATE(DISTINCTCOUNT('A_R MALIN'[Reservation_class]);FILTER('A_R MALIN';'A_R MALIN'[identification number]='A_R MALIN'[identification number])) 
I get 4 (it's counting all the different values in the columns and not for each identification number even if i use FILTER) while i'm trying to get 1 or 2
 
i really hope someone can help me with this
 
thx
1 ACCEPTED SOLUTION
saurabh_kedia_
Microsoft Employee
Microsoft Employee

Hi Jibril,
 
Kindly try the below DAX, if it works accept this as solution & give kudos!
 
Type =
VAR Count_Flight = CALCULATE(DISTINCTCOUNT('A_R MALIN'[Reservation Class]),ALLEXCEPT('A_R MALIN','A_R MALIN'[Identification Number]))
RETURN
IF(Count_Flight>1,"Mix","1st Class")
 
Regards,
Saurabh

View solution in original post

3 REPLIES 3
saurabh_kedia_
Microsoft Employee
Microsoft Employee

Hi Jibril,
 
Kindly try the below DAX, if it works accept this as solution & give kudos!
 
Type =
VAR Count_Flight = CALCULATE(DISTINCTCOUNT('A_R MALIN'[Reservation Class]),ALLEXCEPT('A_R MALIN','A_R MALIN'[Identification Number]))
RETURN
IF(Count_Flight>1,"Mix","1st Class")
 
Regards,
Saurabh
Anonymous
Not applicable

thank you it work, didn't know before the all except!! 🙂

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Seems you are just missing the earlier function

 

Column =
CALCULATE (
    DISTINCTCOUNT ( 'A_R MALIN'[Reservation class] ),
    FILTER (
        'A_R MALIN',
        'A_R MALIN'[identification number]
            = EARLIER ( 'A_R MALIN'[identification number] )
    )
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.