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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
inti
Regular Visitor

DAX expression. HELP

Hi everyone, i'm new at DAX and I need to solve the following:

 

1. I have a table with a receipt date "tb1"

2. I have a measure that tells me the average time my client pays "ppc"

 

What I want to calculate is the date i'll be payed by my clients acording to the measure based on receipt date

 

For example, the client1 pays around 30 days after the receipt is send, the new column should sum the date on the receipt plus the average time in the measure.

 

Thank you in advance!!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Inti,

 

Sounds like you want to add days to a specified date. For this purpose you could use the 'DATEADD' function.

 

To help you, I'm making these assumptions:
1) "tb1" is a column in the format dd-mm-yyy.
2) "ppc" is an integer, representating a number of days.

3) The result is a new column, which adds the value of "ppc" to the corresponding date in "tb1"

 

In the table containing your "tb1" column, create a new column in the "Home" tab. The formula for this new column would be:


newcolumn = DATEADD('Tablename'[tb1], [ppc], DAY)

 

Hopefully this solves your question. Please mark this answer as a solution if it does!

 

 

View solution in original post

6 REPLIES 6
inti
Regular Visitor

Thank you very much for all the help provided. I have found a solution. 

v-jialongy-msft
Community Support
Community Support

Hi @inti 

 

Can you  provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.

 

 

Best Regards,

Jayleny

inti
Regular Visitor

Yes, the expression is great! But now i'm learning that there is a circular reference between "ppc" and the date column "tb1"... actually the "ppc" measure uses the same column to calculate the interger output.

 

How can i ad a filter or solution to this?

Anonymous
Not applicable

Could you give me the DAX for the "ppc" measure? You might be able to use other data/other columns to achieve your goal.

Yes, of course:

PPC = CALCULATE(
		DIVIDE(SUM(IMPUTACION_VTA[NUMERAL]),SUM(IMPUTACION_VTA[IMPORT_CAN]),0),
		CLIENTES[AREA]<>"M",
		CLIENTES[AREA]<>"L",
		CLIENTES[AREA]<>"V"
		) 

I already tried to encapsulate the "PPC" measure declaring a variable and changing the table to extract the date ("imputacion_vta" for "saldo_cta_cte hist") but no success

Payment forecast = 
VAR ppc_valor = [PPC]
RETURN
CALCULATE(
    ppc_valor,
    FILTER(
        'SALDO_CTA_CTE HIST',
        'SALDO_CTA_CTE HIST'[FECHA_EMI] = DATEADD('SALDO_CTA_CTE HIST'[FECHA_EMI],ppc_valor,DAY)))

 

Aditional info:

I'm creating this column in the "Imputacion_Vta" table, ¿Can this be the problem?

 

The table that reflect our ERP data is "Doc_Vta_Cab"

The table is used to create many calculated columns is "Imputacion_Vta"

PPC is a measure

 

Relations between tables:

"Imputacion_Vta" many to one with "Doc_Vta_Cab",

Cross filter direction: both, 

Relation active checkbox: true

 

 

Thank you in advance!

Anonymous
Not applicable

Hi Inti,

 

Sounds like you want to add days to a specified date. For this purpose you could use the 'DATEADD' function.

 

To help you, I'm making these assumptions:
1) "tb1" is a column in the format dd-mm-yyy.
2) "ppc" is an integer, representating a number of days.

3) The result is a new column, which adds the value of "ppc" to the corresponding date in "tb1"

 

In the table containing your "tb1" column, create a new column in the "Home" tab. The formula for this new column would be:


newcolumn = DATEADD('Tablename'[tb1], [ppc], DAY)

 

Hopefully this solves your question. Please mark this answer as a solution if it does!

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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