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.
Hello everyone.
I am having a problem with a DAX query here...
Basically, i need to sum the first historical sale of each client for only 3 months, then i need to go blank for the next months upcoming. Like this:
The problem is that in the totals, it not keep summing after the 3 months.
What i did was:
Sales 3 months after first historical sale =
Solved! Go to Solution.
Hello Everyone, Chat GPT helped me 🙂
If anyone needs this solution please be my guest:
VAR Alta_Por_Cliente =
ADDCOLUMNS(
SUMMARIZE('Stores', 'Stores'[Cust_ID String]),
"Fecha Alta", CALCULATE(FIRSTDATE('Stores'[Fecha]), FILTER(ALL(Calendario[Date]),[$ TPV Financing post cierre]>0))
)
VAR Tres_Meses_After_Alta =
ADDCOLUMNS(
Alta_Por_Cliente,
"Tres Meses Después", EOMONTH([Fecha Alta], 3)
)
RETURN
SUMX(
Tres_Meses_After_Alta,
VAR ClienteActual = 'Stores'[Cust_ID String]
VAR FechaAlta = [Fecha Alta]
VAR TresMesesDespues = [Tres Meses Después]
RETURN
CALCULATE(
[$ TPV Financing post cierre],
'Stores'[Cust_ID String] = ClienteActual &&
'Stores'[Fecha] >= FechaAlta &&
'Stores'[Fecha] <= TresMesesDespues
)
)
Table Stores is my sales/Fact table in this case and TPV Financed is my sales metric
Hello Everyone, Chat GPT helped me 🙂
If anyone needs this solution please be my guest:
VAR Alta_Por_Cliente =
ADDCOLUMNS(
SUMMARIZE('Stores', 'Stores'[Cust_ID String]),
"Fecha Alta", CALCULATE(FIRSTDATE('Stores'[Fecha]), FILTER(ALL(Calendario[Date]),[$ TPV Financing post cierre]>0))
)
VAR Tres_Meses_After_Alta =
ADDCOLUMNS(
Alta_Por_Cliente,
"Tres Meses Después", EOMONTH([Fecha Alta], 3)
)
RETURN
SUMX(
Tres_Meses_After_Alta,
VAR ClienteActual = 'Stores'[Cust_ID String]
VAR FechaAlta = [Fecha Alta]
VAR TresMesesDespues = [Tres Meses Después]
RETURN
CALCULATE(
[$ TPV Financing post cierre],
'Stores'[Cust_ID String] = ClienteActual &&
'Stores'[Fecha] >= FechaAlta &&
'Stores'[Fecha] <= TresMesesDespues
)
)
Table Stores is my sales/Fact table in this case and TPV Financed is my sales metric
Hello @DataNinja777 !
It doesnt work!
It only changed the numbers and I think wrongly.
CUST is my Clients data dim and Stores is my fact/sales table.
Do you know what i am doing wrong?
Hi @alextf94
Thanks for your feedback. I did further testing using the dummy data I created to mimic your data, and found out that if you create a separate measure which references your original measure and sumxing over the customer table, it produces your required output. I cannot explain why this separate measure approach works while the combined measure approach didn't work. The 1st table is your original measure's behavior, and the 2nd measure is the sumxing of your original measure in a separate measure.
Sumxing over customer table = sumx(CUST,[Sales 3 months after first historical sale])
If sumxing over the entire Customer table doesn't work, please try values(Cust[Customer]). I cannot explain the technical intricacies of why it works and the other doesn't work, but you can get your required output in the manner above.
Hello @DataNinja777 !
First of all thank you for the response! The issue is that if i whant to put the same metric in a Line Chart, it gets me to this:
Thats why i think the issue is with the totals of the same table i posted before! When i said totals i was referring to this:
Hi @alextf94
Could you clarify what is the issue? You total is only showing the first 3 months for each customer and your visual shows the correct summation of the visual over time dimension. Do you consider this as an issue?
Best regards,
Hi @alextf94
Thank you for your clarification. I am assuming that your Customer ID is from your customer master data dimension table which has relationship with your fact table. I think Sumxing over customer table will solve your problem of not correctly summing over all the customers, and just suming over the first 3 months' customers.
Best regards,
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
15 | |
10 | |
9 | |
8 | |
6 |
User | Count |
---|---|
14 | |
12 | |
12 | |
11 | |
10 |