cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Anonymous
Not applicable

## Show only LAST NON BLANK value in Cards

Hello All,

I have a table as below

I have written below calculated column to get the last non blank value from column B

`c = var temp = Table1[A]return CALCULATE(LASTNONBLANK(Table1[B],Table1[B]),ALL(Table1),Table1[A]<=temp)`

And it gives me

But when i used a card visual on this c calculated column

it is showing the all sum of values i.e 14

I would like to show a card visual which can only show the value of LAST NON BLANK from column B i.e value 3.

Mohan V

1 ACCEPTED SOLUTION
Microsoft

@Anonymous

When you put a field into a Card Visual, it will be aggregated. In this scenario, you need to create a measure instead of calculated column. You need to calculate the LastNonBlankDate first, then use it to get the corresponding column B. Please refer to DAX below:

```LastNonBlank B =
var LastNonBlankDate=CALCULATE(MAX(Table1[Date]),FILTER(ALL(Table1),Table1[Date]<=MAX(Table1[Date]) && Table1[B]<>0))
return
CALCULATE(SUM(Table1[B]),
FILTER(ALL(Table1),Table1[Date]=LastNonBlankDate)
)```

Regards,

5 REPLIES 5
Microsoft

@Anonymous

When you put a field into a Card Visual, it will be aggregated. In this scenario, you need to create a measure instead of calculated column. You need to calculate the LastNonBlankDate first, then use it to get the corresponding column B. Please refer to DAX below:

```LastNonBlank B =
var LastNonBlankDate=CALCULATE(MAX(Table1[Date]),FILTER(ALL(Table1),Table1[Date]<=MAX(Table1[Date]) && Table1[B]<>0))
return
CALCULATE(SUM(Table1[B]),
FILTER(ALL(Table1),Table1[Date]=LastNonBlankDate)
)```

Regards,

Frequent Visitor

Hi, how would you do the same thing but having 2 tables? I have the same problem but i have my date table apart from my dataset. Actually, im using this dax measure but now been october it doesn't show me the value of this month, it show's me the previous one.

dataset

Impactful Individual

thanks it works perfectly for me.

I just need that to work on a more filtered context, with my products filtered.

Currently, your measure is returning the value of a sum for all products, whatever product is filtered. How to make it specific to each product ?

is it something like :

```LastNonBlank B =
var LastNonBlankDate=CALCULATE(MAX(Table1[Date]),FILTER(ALL(Table1),Table1[Date]<=MAX(Table1[Date]) && Table1[B]<>0))
return
CALCULATE(SUMX(Table1[B],(Table1[Products]),
FILTER(ALL(Table1),Table1[Date]=LastNonBlankDate)
) ```

Thanks !

Impactful Individual

https://1drv.ms/u/s!AkOv33tEaCSwpH1X-dYFZx5dNfXe

your measure is in the dataset with same name

Super User

I'm not sure what all of the other DAX is about, but I believe what you are going for is:

`Measure = LASTNONBLANK(Table1[B],[B])`

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors