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
JPSCHAFFER
Frequent Visitor

DAX Question: copy column value but change at certain interval (text)

I would like to copy the rows from the first column to the second. 

Whenever the logic comes to a row with "VC" I would like "VC" copied instead until the next "VC" value. 

Then, it returns to copying the row in the first column.

 

Column(Value to return)
XXXX
XXXX
XXXX
XXXX
VCVC
BYVC
BYVC
BYVC
BYVC
BYVC
VCVC
BYBY
BYBY
BYBY
BYBY
BYBY
VCVC
BYVC
XXVC
VCVC
XXXX
XXXX

 

8 REPLIES 8
Anonymous
Not applicable

Power Query is the tool to do such things... Please have a look:

 

https://1drv.ms/u/s!ApyQEauTSLtOgYMozxOFMkHiel9nYg?e=8az3Ym

 

Best

D

Can you send this to joshscha@gmail.com?

@Anonymous 

Anonymous
Not applicable

Again... Such things are easily performed in Power Query and should be performed there. DAX is not a data mashup language; it's a Data Analysis eXpressions language.

Best
D
JPSCHAFFER
Frequent Visitor

@Anonymous

So interesting! I'll try as soon as I can and get back to you. 

 

Anonymous
Not applicable

I will give you logic just check for occurance of vc and increment it by 1.

So everytime we need to fill vc from odd to even.
Greg_Deckler
Super User
Super User

Having a hard time wrapping my head around the logic that is desired here. But, mabye something like Cthulhu: 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Cthulhu/td-p/509739


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I changed the discription a bit, maybe it's clearer. thanks. 

Anonymous
Not applicable

Hi @JPSCHAFFER 

 

Create one index column.

 

Then create below two columns

Rank =
VAr rank_check=RANKX(FILTER(Sheet4,Sheet4[Column]=EARLIER(Sheet4[Column])&&Sheet4[Column]="VC"),Sheet4[Index],,ASC)
return
IF(Sheet4[Column]="VC",rank_check,BLANK())
 
Output =
var final= IF(Sheet4[Rank]=BLANK(),CALCULATE(LASTNONBLANK(Sheet4[Rank],0),FILTER(Sheet4,Sheet4[Index]<EARLIER(Sheet4[Index]))))
return
IF(MOD(final,2)>0,"VC",Sheet4[Column])
 
 
Capture6.PNG
 
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

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.

Top Solution Authors