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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.