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
Miro1994
Regular Visitor

Return last nonblank value in matrix visual

Hello,

i can't find any solution for this problem in Power BI, i hope it is able to create in DAX.

I made this matrix, the problem is, that if there are no values (balance) for one of category in ZUONR for some dates (f. e. 2022-04 and 2022-05) i need to return last nonblank value. Simply, in this case i want to have for RI in both dates 2022-04 and 2022-05 values 525.

Miro1994_0-1679984521981.png


If anybody know the solution, i will be thankful!

(table with data)

Miro1994_0-1679988562809.png

 

2 ACCEPTED SOLUTIONS
barritown
Super User
Super User

Hello,

 

My model based on your table looks like this:

barritown_0-1679999737230.png

 

The measure which solves your problem looks like this:

Custom Sum = 
VAR CurrentMonth = MAX ( Months[date] )
VAR MaxNonBlankMonth = CALCULATE ( MAX ( data[date] ), REMOVEFILTERS ( Months[date] ), Months[date] <= CurrentMonth )
RETURN CALCULATE ( SUM (data[balance]),
            REMOVEFILTERS ( Months[date] ),
            Months[date] = MaxNonBlankMonth )

 

Here's the proof that it works:

barritown_1-1680000161811.png

 

Should you need some more details, please let me know.

View solution in original post

Hi,

 

I have a feeling that there is some more proper way to achieve the result you need, but I can come up with such a proposal:

Custom sum with groups = 
VAR CustomSums = SUMMARIZE ( Groups, Groups[ZUONR], "CustomSum", [Custom Sum] )
RETURN SUMX (CustomSums, [CustomSum] )

 

This measure is built on top of the yesterday one as you can see.

 

The model is pretty much the same.

barritown_0-1680077646555.png

 

Here is the result:

barritown_1-1680077772799.png

 

View solution in original post

5 REPLIES 5
barritown
Super User
Super User

Hello,

 

My model based on your table looks like this:

barritown_0-1679999737230.png

 

The measure which solves your problem looks like this:

Custom Sum = 
VAR CurrentMonth = MAX ( Months[date] )
VAR MaxNonBlankMonth = CALCULATE ( MAX ( data[date] ), REMOVEFILTERS ( Months[date] ), Months[date] <= CurrentMonth )
RETURN CALCULATE ( SUM (data[balance]),
            REMOVEFILTERS ( Months[date] ),
            Months[date] = MaxNonBlankMonth )

 

Here's the proof that it works:

barritown_1-1680000161811.png

 

Should you need some more details, please let me know.

I have one additional question ...  If there is more than 1 categorical variable in that matrix, for example

Miro1994_0-1680007193669.png

I need to SUM that groups (Brutto and Reinsurance) also with that repeated values 

Miro1994_1-1680007361576.png

Is there any solution for this case please?

Table

Miro1994_2-1680007470209.png

 



Hi,

 

I have a feeling that there is some more proper way to achieve the result you need, but I can come up with such a proposal:

Custom sum with groups = 
VAR CustomSums = SUMMARIZE ( Groups, Groups[ZUONR], "CustomSum", [Custom Sum] )
RETURN SUMX (CustomSums, [CustomSum] )

 

This measure is built on top of the yesterday one as you can see.

 

The model is pretty much the same.

barritown_0-1680077646555.png

 

Here is the result:

barritown_1-1680077772799.png

 

Great! Work fine! Thankx

Thank you very much! It works well!

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.