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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
strombose007
New Member

calculate value on Lastdate if its blank

Hi all,

I am searching for a dax formula that can provides a value from last available date.

 

The Value for the date august and july is missing (only Company 2) and when I use this formula with visual filter on KPI it works:

Measure Last date cogs =

   CALCULATE(
        Sum(Tabelle1[Value]),
            LASTDATE(Tabelle1[Date])

 

But I need a formula that can filter. I tried the following formula:

Measure with filter =
    CALCULATE(SUM('Tabelle1'[Value]),
        FILTER('Tabelle1','Tabelle1'[KPI]="cogs"),
            LASTDATE('Tabelle1'[Date]) )

 

The last date is august 24. But cogs have no available value in august and july but I want the last date that is available (june). 

 

The problem is (I guess), Lastdate funktion identify the last date in the column date and the result is august 24 but for cogs is no data available.

 

 

 

 

 

 

Screenshot 2024-08-29 114902.png

 

Screenshot 2024-08-29 114755.png

 

 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @strombose007 ,

 

You can try this measure.

MEASURE withFILTER =
    VAR _max_date =
        CALCULATE (
            MAX ( 'Tabelle1'[Date] ),
            FILTER ( ALLSELECTED ( Tabelle1 ), 'Tabelle1'[KPI] = "cogs" )
        )
    RETURN
        CALCULATE (
            SUM ( Tabelle1[Value] ),
            FILTER (
                ALLSELECTED ( Tabelle1 ),
                'Tabelle1'[Date] = _max_date
                    && 'Tabelle1'[KPI] = "cogs"
            )
        )

vkaiyuemsft_0-1725000466418.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @strombose007 ,

 

You can try this measure.

MEASURE withFILTER =
    VAR _max_date =
        CALCULATE (
            MAX ( 'Tabelle1'[Date] ),
            FILTER ( ALLSELECTED ( Tabelle1 ), 'Tabelle1'[KPI] = "cogs" )
        )
    RETURN
        CALCULATE (
            SUM ( Tabelle1[Value] ),
            FILTER (
                ALLSELECTED ( Tabelle1 ),
                'Tabelle1'[Date] = _max_date
                    && 'Tabelle1'[KPI] = "cogs"
            )
        )

vkaiyuemsft_0-1725000466418.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

strombose007
New Member

Unfortunately the result is blank. It should display in the visual (right visual) the last available value for the KPI (result 40,537). The current result for cogs in "august" and the "company 2" is blank, because the lastdate returns a value in august but the cogs has no value. I need the last available value of the KPI.

 

Here is the pbi file:

https://drive.google.com/file/d/1kV3XHYiPV36xw4ZB5V43bzyjWRGVwjS5/view?usp=drive_link

 

 

 

 

strombose007
New Member

Hi,

 

no it does not work, because I need the filter in the dax formula FILTER('Tabelle1','Tabelle1'[KPI]="cogs")

then modify the dax like this and try

CALCULATE(
        Sum(Tabelle1[Value]),
         ALLEXCEPT(Tabelle1, Tabelle1[Company]),Tabelle1[Date]=max(Tabelle1[Date]),'Tabelle1'[KPI]="cogs"
)


Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/
Rupak_bi
Super User
Super User

Hi,

Below DAX should work.

CALCULATE(
        Sum(Tabelle1[Value]),
           ALLEXCEPT(Tabelle1, Tabelle1[Company],Tabelle1[Kpi]),Tabelle1[Date]=max(Tabelle1[Date])
)
If this works, plz accept as solution, else Plz let me know


Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.