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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Carlo1975
Helper I
Helper I

Find and Repeat Value

Hi, I have the same topic in Power Query and the reply about mahoneypat it's ok, it works in power query but then, when I go to update power BI it doesn't work anymore (twice I blocked the update after 10 hours). So, I would to know if a can do it with DAX (maybe it's better)

 

I try to explain, I have a table with 3 columns ordered for IdLotto and Use (in power query, I don't know if is the same after in DAX):

 

IndexIdLottoUse
100000070_LOI1 - Residential
200000071_LOI1 - Residential
300000072_LOI1 - Residential
400000074_LOI1 - Residential
500000075_LOI2 - Hospitality
600000075_LOI3 - Industrial
700000086_LOI1 - Residential
800000086_LOI3 - Industrial
900000094_LOI1 - Residential
1000000094_LOI6 - Parking
1100000094_LOI8 - Other
1200000098_LOI1 - Residential
1300000100_LOI6 - Parking

 

I have to add a new column. For each IdLotto (which can be repeated),  I have to insert in the new column the first value find in Use (the order I do for "IdLotto" and "use" allows me to have the "Use" column always sorted by priority through the initial number).

At the end I will have a table like this:

 

IndexIdLottoUseUse_For_Lot
100000070_LOI1 - Residential1 - Residential
200000071_LOI1 - Residential1 - Residential
300000072_LOI1 - Residential1 - Residential
400000074_LOI1 - Residential1 - Residential
500000075_LOI2 - Hospitality2 - Hospitality
600000075_LOI3 - Industrial2 - Hospitality
700000086_LOI1 - Residential1 - Residential
800000086_LOI3 - Industrial1 - Residential
900000094_LOI1 - Residential1 - Residential
1000000094_LOI6 - Parking1 - Residential
1100000094_LOI8 - Other1 - Residential
1200000098_LOI1 - Residential1 - Residential
1300000100_LOI6 - Parking6 - Parking

 

and so for IdLotto 00000075_LOI (bold) I will write 2 - Hospitlity on all the 2 row of ID 00000075_LOI.

For  IdLotto 00000094_LOI I will write 1 - Residential 

 

It's possible to do it with DAX?

Thank you

Carlo

 

1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

I think I suggested a DAX column in the last post.  While a Table.Buffer step would help that one dramatically, this is best done with DAX.  Here is a column expression for it.

 

Use For Lot =
CALCULATE (
    FIRSTNONBLANKVALUE (
        Buildings[Index],
        MIN ( Buildings[Use] )
    ),
    ALLEXCEPT (
        Buildings,
        Buildings[IdLotto]
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.