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
vojtechsima
Super User
Super User

Virtual Table inside Measure - strange behaviour

Hi, guys,
I got stuck on one issue and I can't figure out why it works like that. I mean I have an idea, but it is still strange.

I have this sample data:

FlightDate|Number|DepartureTime

05.05.2022 123 05:05:59
04.05.2022 123 07:05:59
06.03.2022 56 07:05:59
09.02.2022 58 07:05:59
10.02.2022 456 07:05:59
01.01.2022 1232 07:03:59
01.01.2022 1232 07:05:59


I am trying to figure out if I have [Number] more than one time in my table and If so, evaluate whether it has the same [FlightDate] if not then return False.

I have an idea how to do it but I got stuck on some strange behaviour of the virtual table.
This is my table visual with the current Measure:

TestForDateTable = 
    var currentNumber = MAX(Flights[Number])
    var sameFlightDate = ADDCOLUMNS(SUMMARIZE(Flights, Flights[Number], Flights[FlightDate], "CountOfDuplicates", COUNTROWS(Flights)),"UniqueNumber", Flights[Number])
    var summrazizeNumbes = ADDCOLUMNS(SUMMARIZE(Flights, Flights[Number], "CountOfNumbers", COUNTROWS(Flights)), "UniqueNumber", Flights[Number])

    var MatchNumbers = MAXX(FILTER(sameFlightDate, currentNumber = [UniqueNumber]), [CountOfDuplicates])
    var MatchFlightDate = MAXX(FILTER(sameFlightDate, MatchNumbers = [UniqueNumber]), [CountOfDuplicates])


    return MatchNumbers

vojtechsima_0-1650976210205.png

This is what the Virtual Table looks like physically:

vojtechsima_1-1650976234659.png
So basically what I want to do is to take the Current Number filter inside the Virtual Table and assign the proper Count and then display it, however it somehow Displays always 1 instead of 2 when it should be 2. It works when I remove all other columns from my Table Visual but it has to work regardless of the Column I put into the Visual, right?


Could someone please advise what I do wrong and which filter context should I use to eliminate the context it'S getting? I already tried to use ALL and the whole ALL family but it doesn't change the outcome.

Thank you






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

You can use

Num Different Flights = 
var currentNumber = SELECTEDVALUE(Flights[Number])
var summaryTable = CALCULATETABLE( SUMMARIZE( Flights, Flights[FlightDate]), REMOVEFIlTERS(Flights), Flights[Number] = currentNumber)
return COUNTROWS( summaryTable )

View solution in original post

CNENFRNL
Community Champion
Community Champion

I don't see any necessity of complexity according to your description in case of such a simple question.

CNENFRNL_0-1650978628830.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

I don't see any necessity of complexity according to your description in case of such a simple question.

CNENFRNL_0-1650978628830.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi, @CNENFRNL 
Thank you, that's quite the optimization. 😄

Didn't think about it like that.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
johnt75
Super User
Super User

You can use

Num Different Flights = 
var currentNumber = SELECTEDVALUE(Flights[Number])
var summaryTable = CALCULATETABLE( SUMMARIZE( Flights, Flights[FlightDate]), REMOVEFIlTERS(Flights), Flights[Number] = currentNumber)
return COUNTROWS( summaryTable )

Hi, @johnt75 
Didn't think about this point of view. Thank you, it obviously worked.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

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.