Forum Discussion

Mekist's avatar
Mekist
Icon for Helper III rankHelper III
1 year ago
Solved

4 quarter collection

Merhaba

Her şey normale dönene kadar 4 çeyrekte geriye doğru kar toplamaya çalışıyorum

4 çeyreğin eksik verilerinin toplamını almak istemiyorum. Toplamların 4 çeyreğe ait veri içerip içermediğini nasıl kontrol edebilirim?

 

 

 

Birikimli Kar =
VAR Donem1 = MAX('Dönem'[Dönem])
VAR Bitiş2 =
    HESAPLAMAK(
        MAX('Dönem'[Dönem]),
        FİLTRE(
            TÜMÜ('Dönem'),
            'Dönem'[Dönem] < Donem1
        ))
VAR Bitiş3 =
    HESAPLAMAK(
        MAX('Dönem'[Dönem]),
        FİLTRE(
            TÜMÜ('Dönem'),
            'Dönem'[Dönem] < Donem2
        ))
VAR Bitiş4 =
    HESAPLAMAK(
        MAX('Dönem'[Dönem]),
        FİLTRE(
            TÜMÜ('Dönem'),
            'Dönem'[Dönem] < Donem3
        ))
VAR TamamKar1 =
    HESAPLA([Net Kar],
        'Dönem'[Dönem] = Donem1
    )
VAR TamamKar2 =
    HESAPLA([Net Kar],
        'Dönem'[Dönem] = Donem2
    )
VAR BitişKar3 =
    HESAPLA([Net Kar],
        'Dönem'[Dönem] = Donem3
    )
VAR TamamKar4 =
    HESAPLA([Net Kar],
        'Dönem'[Dönem] = Dönem4
    )
GERİ DÖNMEK
DonemKar1 +DonemKar2 +DonemKar3 + DonemKar4

 

 

PeriodValue4 Quarter Total 
2024/06175.809.561,003.101.989.727,00Evet
2024/03-11.110.597,003.398.882.907,00Evet
2023/121.776.945.363,004.446.245.751,00Evet
2023/091.160.345.400,002.669.300.388,00Hayır
2023/06472.702.741,001.508.954.988,00Hayır
2023/031.036.252.247,001.036.252.247,00Hayır
  • No need to do this in DAX?

     

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY7LDYQwFAN7yTk4fn9SC6L/NhYJIm0OPs3Y8nU1pfpgDkrrTSpwciJSOtnuvri9/BCBCBGz/rgN0a+PqsT0gKVtBucyJAl7DCd34/vgpSg+cdm5rQVaQkOh/r64fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Period = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Period", type date}, {"Value", Currency.Type}},"tr"),
        #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Period", Order.Ascending}}),
        #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
        #"Added Custom" = Table.AddColumn(#"Added Index", "4 Quarter Total", (k)=> List.Sum(Table.SelectRows(#"Added Index",each [Index]<=k[Index] and [Index]>=k[Index]-3)[Value]),Currency.Type),
        #"Added Custom1" = Table.AddColumn(#"Added Custom", "Complete", (k)=> if Table.RowCount(Table.SelectRows(#"Added Index",each [Index]<=k[Index] and [Index]>=k[Index]-3))=4 then "yes" else "no", type text),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index"}),
        #"Sorted Rows1" = Table.Sort(#"Removed Columns",{{"Period", Order.Descending}})
    in
        #"Sorted Rows1"

     

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

     

    But if you want - here is the DAX version

     

     

3 Replies

  • No need to do this in DAX?

     

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY7LDYQwFAN7yTk4fn9SC6L/NhYJIm0OPs3Y8nU1pfpgDkrrTSpwciJSOtnuvri9/BCBCBGz/rgN0a+PqsT0gKVtBucyJAl7DCd34/vgpSg+cdm5rQVaQkOh/r64fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Period = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Period", type date}, {"Value", Currency.Type}},"tr"),
        #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Period", Order.Ascending}}),
        #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
        #"Added Custom" = Table.AddColumn(#"Added Index", "4 Quarter Total", (k)=> List.Sum(Table.SelectRows(#"Added Index",each [Index]<=k[Index] and [Index]>=k[Index]-3)[Value]),Currency.Type),
        #"Added Custom1" = Table.AddColumn(#"Added Custom", "Complete", (k)=> if Table.RowCount(Table.SelectRows(#"Added Index",each [Index]<=k[Index] and [Index]>=k[Index]-3))=4 then "yes" else "no", type text),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index"}),
        #"Sorted Rows1" = Table.Sort(#"Removed Columns",{{"Period", Order.Descending}})
    in
        #"Sorted Rows1"

     

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

     

    But if you want - here is the DAX version

     

     

    • Mekist's avatar
      Mekist
      Icon for Helper III rankHelper III

      Hello

      The original file contains the company name and other data, there is more data, I have sent short data as an example.

      The measure you shared created the 2024/09 period. That period does not exist for this company. How can we overcome this?

      Çalışma pbix 

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        I see that period.

         

         

        You would need to adjust the measure to use the fact tables, not the dimension tables.  Your Hisse column doesn't drive any dates.