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

Looking for ideas on UNIONX or DISTINCTX

I am still looking for ways to work around the missing UNIONX command in DAX - the ability to append an arbitrary number of table variables or more precisely lists (single column table variables) inside a table variable.

 

Here is the Power Query equivalent:

 

 

 

 

let
    Source = #table({"Start","End"},{{2,3},{3,4},{6,7}}),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each {[Start]..[End]})
in
    List.Distinct(List.Combine(#"Added Custom"[Custom]))

 

 

 

 

 

The main premise is to handle more than two overlapping intervals without duplication of the sample points (EDIT: while also accounting for gaps). It is extremely easy to do in Power Query as per the above, and it is reasonably easy to do graphically. But the numerical solution eludes me.

 

(I have raised an idea for UNIONX back in 2021 and it has so far roared to a single vote - mine. Microsoft Idea)  

1 ACCEPTED SOLUTION
jpessoa8
Continued Contributor
Continued Contributor

@lbendlin,

 

I think you dind't look correctly to the outcome of the DAX expression. The MAX measures is just to get the corresping "end" list value for each "start" value. It will be the same if I used SELECTEDVALUE().


Using your example of numeric lists, but with numbers even further apart:


List1 : from 1 to 5

List2: from 10 to 14

List3: from 20 to 35

 

The new calculated table DAX Expression :

UNIOX_NUMERIC = 
DISTINCT(
	SELECTCOLUMNS(
		GENERATE(
			VALUES('NumericTable'[Start]),
			VAR EndValue = CALCULATE(MAX('NumericTable'[End]))
			RETURN
				GENERATESERIES(
					'NumericTable'[Start],
					EndValue
				)
		),
		"Value",
		[Value]
	)
)

 

With this I got the following list of numbers:

1,2,3,4,5,10,11,12,13,14,20,21,222,23,24,25,26,27,28,29,30,31,32,33,34,35

jpessoa8_0-1700924118881.png

 

Isn't this what you were looking for?

 

Here is the PowerBI file with both scenarios : https://we.tl/t-zNZ6WSSUSB

 

For additional help, please @ me in your reply!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

Thank you, that approach works. Testing at scale now.

Here's a slightly different setup but the technical result is the same

 

 

 

UNIONX_NUMERIC = 
DISTINCT(
    SELECTCOLUMNS(
        GENERATE(
		SUMMARIZECOLUMNS(NumericTable[Start],NumericTable[End]),
		GENERATESERIES([Start],[End])
	),"Value",[Value]
    )
)

 

 

jpessoa8
Continued Contributor
Continued Contributor

Hi @lbendlin ,

 

I took a look at the Microsoft Idea you've provided since I was having a hard time understanding the logic of the dataset in this topic.

Considering the dates scenario on the idea page, isn't this a possible solution in DAX : 

EVALUATE
SELECTCOLUMNS(
	GENERATE(
		VALUES('Table'[Start]),
		VAR EndDate = CALCULATE(MAX('Table'[End]))
		RETURN
			CALENDAR(
				'Table'[Start],
				EndDate
			)
	),
	"Date",
	[Date]
)

 

With this dataset :

jpessoa8_1-1700855485458.png

 

This is the result I've obtained:

jpessoa8_2-1700855519469.png

Here is the PowerBI file I've used : https://we.tl/t-9kiA3jSR8z

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

@jpessoa8  I will have to be more precise in my request.  Let's assume I have  an arbitrary number of lists.  For this exercise three lists will suffice

 

List 1:  from 2 to 3

List 2: from 3 to 4

List 3: from 6 to 7

 

Now I want to find the distinct values for the combination of all these lists, and the result should be

 

2,3,4,6,7

 

So the clarification will be that there will be overlaps between the lists but also gaps.   Meaning that your Min/Max approach is not applicable, unfortunately.

jpessoa8
Continued Contributor
Continued Contributor

@lbendlin,

 

I think you dind't look correctly to the outcome of the DAX expression. The MAX measures is just to get the corresping "end" list value for each "start" value. It will be the same if I used SELECTEDVALUE().


Using your example of numeric lists, but with numbers even further apart:


List1 : from 1 to 5

List2: from 10 to 14

List3: from 20 to 35

 

The new calculated table DAX Expression :

UNIOX_NUMERIC = 
DISTINCT(
	SELECTCOLUMNS(
		GENERATE(
			VALUES('NumericTable'[Start]),
			VAR EndValue = CALCULATE(MAX('NumericTable'[End]))
			RETURN
				GENERATESERIES(
					'NumericTable'[Start],
					EndValue
				)
		),
		"Value",
		[Value]
	)
)

 

With this I got the following list of numbers:

1,2,3,4,5,10,11,12,13,14,20,21,222,23,24,25,26,27,28,29,30,31,32,33,34,35

jpessoa8_0-1700924118881.png

 

Isn't this what you were looking for?

 

Here is the PowerBI file with both scenarios : https://we.tl/t-zNZ6WSSUSB

 

For additional help, please @ me in your reply!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

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.