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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jch2shill
Frequent Visitor

Delimited data as a filter in a measure

Hello everyone,

 

I have data coming into Power BI from Dynamics Business Central. It is in dot and pipe delimited format. The data could have many iterations of dots and pipes for example:

 

jch2shill_0-1692733435078.png

 

 

 

This is a simplified example but I need to use the values in that column as filters for my measure. For example, my measure to sum the amount of sales, would look like:

 

Calculate(

Sum(Sales[Amount]),

filter(GL Accounts,GL Accounts[GLNumber]>=”70000” && Accounts[GLNumber]<=”70600” || Accounts[GLNumber]=”67760”

)

                )

 

My question is do I need to split and list the many combinations of numbers for that column or can I use the column as it is in my measure? I do not want to create a measure (like in my example above) for every possible row from by GL Account table.

 

Thank you for any direction you can send me.

3 REPLIES 3
jch2shill
Frequent Visitor

Thank you. That gives me a direction to go in. I will have to figure out how to make it dynamic as the position of the numbers with the dots and pipes is random. That is, in your second line of data above, it could easily be 70000..70600|67760

 

@jch2shill ,

The permutations and combinations were my main concern.  Hence, why I only wanted to give direction.
With the variety of text functions available, you can also add a condition to determine where your "|" and ".." are and then determine how to extract the GL Acct number.  Glad you were able to grasp the concept.

Good Luck!

rsbin
Super User
Super User

@jch2shill ,

Not sure if I have an exact solution for you, but I will attempt to show you how I would tackle.
Appears you want to set up your GL Accounts as you have MIN, MAX, and Other.
So in your Measure you would refer to these fields rather than exact Acct #'s. 

To get there, I attempted to use the Split by Delimiter function in Power Query, but didn't quite work out for me.

So, let's do it in DAX.  Started out with a few examples.

Original

65000..67300
67760|70000..70600
86000

Then created 3 new Columns:

MinGL = SWITCH(
           TRUE(),
           AND( CONTAINSSTRING( [Original], ".." )=TRUE(), CONTAINSSTRING( [Original], "|" )=FALSE() ), LEFT( [Original], 5 ),
           AND( CONTAINSSTRING( [Original], "|"), CONTAINSSTRING( [Original], ".." ) ), MID( [Original], 7, 5 ),
           [Original] )

MaxGL = SWITCH(
           TRUE(),
           AND( CONTAINSSTRING( [Original], ".." )=TRUE(), CONTAINSSTRING( [Original], "|" )=FALSE() ), RIGHT( [Original], 5 ),
           AND( CONTAINSSTRING( [Original], "|"), CONTAINSSTRING( [Original], ".." ) ), RIGHT( [Original], 5 ),
           [Original] )
OtherGL = SWITCH(
           TRUE(),
           CONTAINSSTRING( [Original], "|"), LEFT( [Original], 5 ),
           "" )

Original                      MinGL   MaxGL   OtherGL

65000..67300 65000 67300  
67760|70000..70600 70000 70600 67760
86000 86000 86000  

Using the SWITCH function, you can then add as many permutations and combinations that your dataset requires.

Hope you are able to understand what I am going for and that you can get it to work for you.  Have attached the pbix for your reference.

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.