Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Boa Tarde
Estou fazendo esse calculo dax no qual tenho uma base de dados onde alguns dias da semana tem o preenchimento com dados e outros não. Preciso que quando não tiver dados eu pego os dados do dia anterior. Exemplo nos meus dados
dia
15/09
14/09
13/09
12/09
10/09
09/09
08/09
Estou no dia 12/09 não tenho dados do dia 11/09 e 10/09 então no meu meu dax está dando 100% eu preciso que ele pegue o dados do dia 09/09 que seria o ultimo dia que tenho dados e faça variação percentual
Solved! Go to Solution.
Hi @raffa_pintto1 ,
Here I create a sample to have a test.
Measure:
M_ULTIMO km =
VAR _STEP1 =
ADDCOLUMNS (
ALL('Calendar'),
"km",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
USERELATIONSHIP ( 'Table'[Data Brev], 'Calendar'[Date] )
),
"km last day",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
FILTER ( 'Table', 'Table'[Data Brev] = EARLIER ( 'Calendar'[Date] ) - 1 )
)
)
VAR _STEP2 =
ADDCOLUMNS (
_STEP1,
"New km",
VAR _LASTNOTBLANK =
MAXX (
FILTER ( _STEP1, [Date] <= EARLIER ( [Date] ) && [km] <> BLANK () ),
[Date]
)
VAR _KM =
SUMX ( FILTER ( _STEP1, [Date] = _LASTNOTBLANK ), [km] )
RETURN
_KM
)
RETURN
SUMX(FILTER(_STEP2,[Date] =MAX('Calendar'[Date])),[New km])
M_D X D =
VAR _STEP1 =
ADDCOLUMNS (
ALL('Calendar'),
"km",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
USERELATIONSHIP ( 'Table'[Data Brev], 'Calendar'[Date] )
),
"D X D",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
FILTER ( 'Table', 'Table'[Data Brev] = EARLIER ( 'Calendar'[Date] ) - 1 )
)
)
VAR _STEP2 =
ADDCOLUMNS (
_STEP1,
"New DXD",
VAR _LASTNOTBLANK =
MAXX (
FILTER ( _STEP1, [Date] <= EARLIER ( [Date] ) && [D X D] <> BLANK () ),
[Date]
)
VAR _DXD =
SUMX ( FILTER ( _STEP1, [Date] = _LASTNOTBLANK ), [D X D] )
RETURN
_DXD
)
RETURN
SUMX(FILTER(_STEP2,[Date] =MAX('Calendar'[Date])),[New DXD])
M_%Mom dia =
DIVIDE([M_ULTIMO km] - [M_D X D],[M_D X D])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @raffa_pintto1 ,
Here I create a sample to have a test.
Measure:
M_ULTIMO km =
VAR _STEP1 =
ADDCOLUMNS (
ALL('Calendar'),
"km",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
USERELATIONSHIP ( 'Table'[Data Brev], 'Calendar'[Date] )
),
"km last day",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
FILTER ( 'Table', 'Table'[Data Brev] = EARLIER ( 'Calendar'[Date] ) - 1 )
)
)
VAR _STEP2 =
ADDCOLUMNS (
_STEP1,
"New km",
VAR _LASTNOTBLANK =
MAXX (
FILTER ( _STEP1, [Date] <= EARLIER ( [Date] ) && [km] <> BLANK () ),
[Date]
)
VAR _KM =
SUMX ( FILTER ( _STEP1, [Date] = _LASTNOTBLANK ), [km] )
RETURN
_KM
)
RETURN
SUMX(FILTER(_STEP2,[Date] =MAX('Calendar'[Date])),[New km])
M_D X D =
VAR _STEP1 =
ADDCOLUMNS (
ALL('Calendar'),
"km",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
USERELATIONSHIP ( 'Table'[Data Brev], 'Calendar'[Date] )
),
"D X D",
CALCULATE (
SUM ( 'Table'[ULTIMO km] ),
FILTER ( 'Table', 'Table'[Data Brev] = EARLIER ( 'Calendar'[Date] ) - 1 )
)
)
VAR _STEP2 =
ADDCOLUMNS (
_STEP1,
"New DXD",
VAR _LASTNOTBLANK =
MAXX (
FILTER ( _STEP1, [Date] <= EARLIER ( [Date] ) && [D X D] <> BLANK () ),
[Date]
)
VAR _DXD =
SUMX ( FILTER ( _STEP1, [Date] = _LASTNOTBLANK ), [D X D] )
RETURN
_DXD
)
RETURN
SUMX(FILTER(_STEP2,[Date] =MAX('Calendar'[Date])),[New DXD])
M_%Mom dia =
DIVIDE([M_ULTIMO km] - [M_D X D],[M_D X D])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You do that using disconnected tables.
Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
User | Count |
---|---|
20 | |
14 | |
11 | |
9 | |
6 |
User | Count |
---|---|
24 | |
23 | |
20 | |
15 | |
10 |