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
eliasayy
Impactful Individual
Impactful Individual

create list of dates with same values on dax

let
    Source = Table.Combine({
    Table.FromRows(
        {{
List.Dates( #date(2022,8, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2022, 7, 31)) , #duration(1, 0, 0, 0)), 
Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error,"Investor A",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
 Table.FromRows(
        {{"8/1/2022","Investor B",-5000,0.05}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"8/1/2022","Investor C",-15000,0.15}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
 Table.FromRows(
        {{"8/1/2022","Investor D",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"9/1/2022","Investor E",-20000,0.2}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    )
}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Investment Company", type text}, {"Initial Value", Currency.Type}, {"Percentage", Percentage.Type}})
in
    #"Changed Type"

i tried to make a code that lists date and i want the same value so for example i nvestor A to always have 10,000 on initial value, 0.1 on percentage

because i want to createa  relationship between table and date table


1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @eliasayy ,

 

According to your M code, I think first part for investor A will return 8 values, however there are only four keys in your table.

 {{
List.Dates( #date(2022,8, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2022, 7, 31)) , #duration(1, 0, 0, 0)), 
Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error,"Investor A",-10000,0.10}}

RicoZhou_0-1663142726074.png

Here I suggest you to try this M code to achieve your goal.

let
    Source = Table.Combine({
    Table.FromRows(
        {{
List.Dates( #date(2022,8, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2022, 7, 31)) , #duration(1, 0, 0, 0)), 
"Investor A",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    )
}),
    #"Expanded Date" = Table.ExpandListColumn(Source, "Date"),
    #"Combine" =
    Table.Combine({
#"Expanded Date",
        Table.FromRows(
        {{"8/1/2022","Investor B",-5000,0.05}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"8/1/2022","Investor C",-15000,0.15}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
 Table.FromRows(
        {{"8/1/2022","Investor D",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"9/1/2022","Investor E",-20000,0.2}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    )
}),
    #"Changed Type" = Table.TransformColumnTypes(Combine,{{"Date", type date}, {"Investment Company", type text}, {"Initial Value", Int64.Type}, {"Percentage", Percentage.Type}})
in
    #"Changed Type"

 Result is as below.

RicoZhou_1-1663142755889.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @eliasayy ,

 

According to your M code, I think first part for investor A will return 8 values, however there are only four keys in your table.

 {{
List.Dates( #date(2022,8, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2022, 7, 31)) , #duration(1, 0, 0, 0)), 
Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error,"Investor A",-10000,0.10}}

RicoZhou_0-1663142726074.png

Here I suggest you to try this M code to achieve your goal.

let
    Source = Table.Combine({
    Table.FromRows(
        {{
List.Dates( #date(2022,8, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2022, 7, 31)) , #duration(1, 0, 0, 0)), 
"Investor A",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    )
}),
    #"Expanded Date" = Table.ExpandListColumn(Source, "Date"),
    #"Combine" =
    Table.Combine({
#"Expanded Date",
        Table.FromRows(
        {{"8/1/2022","Investor B",-5000,0.05}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"8/1/2022","Investor C",-15000,0.15}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
 Table.FromRows(
        {{"8/1/2022","Investor D",-10000,0.10}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    ),
     Table.FromRows(
        {{"9/1/2022","Investor E",-20000,0.2}},
        {"Date", "Investment Company","Initial Value","Percentage"}
    )
}),
    #"Changed Type" = Table.TransformColumnTypes(Combine,{{"Date", type date}, {"Investment Company", type text}, {"Initial Value", Int64.Type}, {"Percentage", Percentage.Type}})
in
    #"Changed Type"

 Result is as below.

RicoZhou_1-1663142755889.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.