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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Data segmentation (indicators)

Hello everyone 🙂

Q How can I extract and name the next Alloc?

I need to know the number of crazy ones in these IDs,

I extracted the first date from the date column

1st = CALCULATE(FIRSTDATE('Tabla2 (2)'[Fecha de Alocación]), ALLEXCEPT('Tabla2 (2)','Tabla2 (2)'[No orden]))

Then I got the first date with the name Alloc_1 and the other Alloc_n

Alloc_1 = if('Tabla2 (2)'[Fecha de Alocación]=BLANK(),"0_ALLOC",if('Tabla2 (2)'[Fecha de Alocación]='Tabla2 (2)'[1st],"Alloc_1","Alloc_n"))

viajero03082_0-1620878743760.png

I have to get the different alloc (alloc_2, alloc_3 ....) with the help of id and dates

viajero03082_1-1620879088898.png


That is, an S1 ID will be Alloc_1, Alloc_2, Alloc_3 because it has 3 different dates

viajero03082_6-1620879836243.png

As you'll notice there may be the same dates for an order and the dates aren't always consecutive

The ultimate goal is to filter the report by this alloc number 2, 3, 4 with the help of how many dates the specific ID has

Here's another example

viajero03082_5-1620879768446.png

We have separate dates and multiple IDs with dates in common and this should have Alloc_1, Alloc_2, Alloc_3, Alloc_4 since it is 4 dates where we try to address that ID

I hope you can help me, I would thank you very much

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @viajero03082 ,

 

You can do this on the query editor by doing the following steps:

  • Group rows by show_id
    • Select the option all rows

MFelix_0-1621250843081.png

  • Add a new column with the syntax below:
Table.AddIndexColumn ([Count], "Index",1)

MFelix_1-1621250890382.png

 

  • Expand the new column created:

MFelix_2-1621250923277.png

  • Add a new custom column with the following syntax:
"Alloc_" & Number.ToText ([Index])

MFelix_3-1621250981845.png

  • Delete the Count column and the Index column:

If you want to do it in dax use the following code:

Alloc =
VAR temp_table =
    FILTER (
        ALL ( 'Table (2)'[show_id], 'Table (2)'[date] ),
        'Table (2)'[show_id] = EARLIER ( 'Table (2)'[show_id] )
            && 'Table (2)'[date] <= EARLIER ( 'Table (2)'[date] )
    )
RETURN
    "Alloc_" & COUNTROWS ( temp_table )

 

See PBIX file with two versions attach.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @viajero03082 ,

 

You can do this on the query editor by doing the following steps:

  • Group rows by show_id
    • Select the option all rows

MFelix_0-1621250843081.png

  • Add a new column with the syntax below:
Table.AddIndexColumn ([Count], "Index",1)

MFelix_1-1621250890382.png

 

  • Expand the new column created:

MFelix_2-1621250923277.png

  • Add a new custom column with the following syntax:
"Alloc_" & Number.ToText ([Index])

MFelix_3-1621250981845.png

  • Delete the Count column and the Index column:

If you want to do it in dax use the following code:

Alloc =
VAR temp_table =
    FILTER (
        ALL ( 'Table (2)'[show_id], 'Table (2)'[date] ),
        'Table (2)'[show_id] = EARLIER ( 'Table (2)'[show_id] )
            && 'Table (2)'[date] <= EARLIER ( 'Table (2)'[date] )
    )
RETURN
    "Alloc_" & COUNTROWS ( temp_table )

 

See PBIX file with two versions attach.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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