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
DYY94
Helper I
Helper I

Dupicate rows using measure

Hello Community, 

 

Is it possible to duplicate rows using a Measure.  

 

This is my measure : 

 

 

 

dates =
VAR str = "2028/04/13-5"
VAR _date =
    FORMAT ( LEFT ( str, 10 ), "yyyy/mm/dd" )
VAR _num =
    RIGHT ( str, 1 )
VAR _cal =
    MID ( str, 11, 1 )
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        YEAR ( [Date] )
            >= YEAR ( _date ) - _num
            && YEAR ( [Date] ) < YEAR ( _date )
            && MONTH ( [Date] ) = MONTH ( _date )
            && DAY ( [Date] ) = DAY ( _date )
    )
VAR _a =
    CONCATENATEX ( tmp, [Date], "
" )
RETURN
    SWITCH ( TRUE (), _cal = "-", _a )

 

 

 

 

If you want to test it , just create this table before:

 

 

Table = CALENDAR(DATE(2022,1,1),DATE(2028,04,13))

 

 

 

- this is the actual output : 

 

Capture2.PNG

 

- Expected Ouput: 

 

ouput.PNG

 

I want split this dates in rows with the same Code_ISIN.

 

Thanks. 

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @DYY94 ;

It is better if you can share a simplified pbix file after removing sensitive information.


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, @v-yalanwu-msft,

 

Thank you so much for your Time.

Here a simplified pbix file to understand the issue. 


https://drive.google.com/file/d/1Y2eAmjcVyWDJozOTxEaNFXh3F9ZeNpmu/view?usp=sharing

 

Thanks. 

v-yalanwu-msft
Community Support
Community Support

Hi, @DYY94 ;

You could try it.

New =
GENERATE (
    SUMMARIZE ( 'Table', [Code], [Maturatie], "1", [Mr/365] ),
    FILTER (
        CALENDAR (
            DATE ( YEAR ( [Maturatie] ) - [Mr/365], MONTH ( [Maturatie] ), DAY ( [Maturatie] ) ),
            DATE ( YEAR ( [Maturatie] ) - 1, MONTH ( [Maturatie] ), DAY ( [Maturatie] ) )
        ),
        MONTH ( [Date] ) = MONTH ( [Maturatie] )
            && DAY ( [Date] ) = DAY ( [Maturatie] )
    )
)

If the above one can't help you get the desired result,It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

Solved: How to upload PBI in Community - Microsoft Power BI Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-yalanwu-msft , 

 

Thanks again for you help ! 

 

I tried you last code , it works fine but it give me always number  '1' for all colmun instead the real numbers from [MR/365].  

 

Ouput : 

 

Capture5.PNG

 

[MR/365] : 

 

MR.PNG

 

Thanks Again ! 

 

v-yalanwu-msft
Community Support
Community Support

Hi, @DYY94 ;

If you want to increase the number of rows, may be we need create a new table by dax such as:

New = 
GENERATE(
SUMMARIZE('Table',[Code], [Maturatie],[Mr/365]),
FILTER(
CALENDAR(
    DATE(YEAR([Maturatie])-[Mr/365],MONTH([Maturatie]),DAY([Maturatie])),
    DATE(YEAR([Maturatie])-1,MONTH([Maturatie]),DAY([Maturatie]))
),MONTH([Date])=MONTH([Maturatie])&&DAY([Date])=DAY([Maturatie])))

The final show:

vyalanwumsft_0-1669704282129.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yalanwu-msft ,

 

Thanks for the solution it's great . 

 

I have only one issue with [MR/365] in my case it's a measure and i can't included in in Summrize ! 

when i replaced with yours it didn't do the calculation. 

 

Here screenshots below : 

 

MR.PNG 

 

capture3.PNG

 

Hope you understand me and Thanks again. 

@v-yalanwu-msft  !

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.