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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
guibenassi
Advocate II
Advocate II

Conditional calculated with date

I have made this measure to get the value of [Custo_tabela-Un] in case that there is no number in a respective date, in this case I look for the previous date to populate the columm, and if there is not a value in the day before I go to 2 days before and then goes on.
The problem is that it only works with the first condition, if I put the second condition no value comes.
 
 
 
Custo_Tab_Un_Corrigido1 =
VAR MediaTabela = sum(tmp_vendas_teste[custo_tabela_un])

 

RETURN
if(
MediaTabela=0;
IF(
Calculate(
MediaTabela;
DATEADD(dCalendario[Date];-1;day)
)=0;
IF(
Calculate(
MediaTabela;
DATEADD(dCalendario[Date];-2;DAY)
)=0;
 
calculate(
MediaTabela;
DATEADD(dCalendario[Date];-2;day)
)
)
;
Calculate(
MediaTabela;
DATEADD(dCalendario[Date];-1;DAY)
)
)
;MediaTabela
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @guibenassi 

Create a measure

Measure = CALCULATE(FIRSTNONBLANK('Table'[value],0),FILTER(ALLSELECTED('calendar'),'calendar'[Date]<MAX('calendar'[Date])))

Capture15.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @guibenassi 

Create a measure

Measure = CALCULATE(FIRSTNONBLANK('Table'[value],0),FILTER(ALLSELECTED('calendar'),'calendar'[Date]<MAX('calendar'[Date])))

Capture15.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the measure. I did just a few improvement to works best.
I include the = in the MAX calendar date and insert an IF for the first value provided.
Above the complete new measure.
Thanks a lot for the solution

@v-juanli-msft 

 

Custo_Tab_Un_Corrig =
VAR Branco = CALCULATE(
FIRSTNONBLANK(tmp_vendas_teste[custo_tabela_un];0);
FILTER(
ALLSELECTED(dCalendario[Date]);
dCalendario[Date]<=MAX(dCalendario[Date])
)
)
RETURN
IF(
Branco=0;
sum(tmp_vendas_teste[custo_tabela_un]);
Branco
)
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you please share the sample data and your expected output for my better understanding.

Best Regards,
@Anonymous 

Anotação 2019-11-25 102526.jpg

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.