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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
hylosko
Helper III
Helper III

Last month from last visible month in table

Hello experts!!!

 

hylosko_1-1655746476891.png

 

In PBI i have sth like this. I need measure which will show me value for last month from last visible month in table.

For example: for 1. it will be 14, for 2. it will be 28, for 3. it will be 94, for 4. it will be 12 

any ideas ?

 

1 ACCEPTED SOLUTION

Hi,

Check the below.

If you need to add more columns but the below measure does not work, please mention.

 

Untitled.png

 

Expected measure: = 
VAR _maxmonthnumber =
    MAXX ( FILTER ( Data, Data[Value] <> BLANK () ), Data[Monthnumber] )
RETURN
    IF (
        HASONEVALUE ( Data[Index] ),
        CALCULATE ( SUM ( Data[Value] ), Data[Monthnumber] = _maxmonthnumber - 1 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
hylosko
Helper III
Helper III

I think it will be not work, if we have more months

 

my situation i like in this picture 

hylosko_0-1655753272939.png

have you maybe other idea for this case ? 

Hi,

Check the below.

If you need to add more columns but the below measure does not work, please mention.

 

Untitled.png

 

Expected measure: = 
VAR _maxmonthnumber =
    MAXX ( FILTER ( Data, Data[Value] <> BLANK () ), Data[Monthnumber] )
RETURN
    IF (
        HASONEVALUE ( Data[Index] ),
        CALCULATE ( SUM ( Data[Value] ), Data[Monthnumber] = _maxmonthnumber - 1 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

but what if i have situation like this 

hylosko_0-1655801955732.png

[monthnumber] is from calendar table

[index] is from indexestable

[value] is measure

 

how i should transform this dax ?

Hi,

Thank you for your feedback. If some of components are coming from different tables, I think the relationships between tables has to be known. Please share your sample pbix file, and then I can try to look into it.

Thanks. 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I assume the table structure needs to be transformed in Power Query Editor like the sample pbix file.

 

Power Query Editor

let
    Source = Source,
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Index"}, {{"ALL", each Table.AddIndexColumn( _, "Monthnumber",1,1) }}),
    #"Expanded ALL" = Table.ExpandTableColumn(#"Grouped Rows", "ALL", {"Attribute", "Value", "Monthnumber"}, {"Attribute", "Value", "Monthnumber"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded ALL",{{"Attribute", type text}, {"Value", Int64.Type}, {"Monthnumber", Int64.Type}})
in
    #"Changed Type"

 

 

And then, load the data and create a measure like below.

 

Untitled.png 

 

Expected measure: =
VAR _maxmonthnumber =
    MAX ( Data[Monthnumber] )
RETURN
    IF (
        HASONEVALUE ( Data[Index] ),
        CALCULATE ( SUM ( Data[Value] ), Data[Monthnumber] = _maxmonthnumber - 1 )
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors