Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi everyone!
I have a table with 4 fields, date, status, product and liters. I have related this table with a dimension of date with date field.
I would like to get the following.
Assuming that the date range selected is from 09/01/2023 to 09/20/2023:
- If the status=A then show only the result for the min date of the selected date range, I mean show just the liters for 09/01/2023
- if the status= B o C show the sum of liters for all the dates between the selected date range.
- if the status=C show the sum of liters for the max date of the selected date range + 1 day, I mean show just the liters for 09/21/2023
According to this, for status A should be 50 liters, for status B should be 114, status C 95 and status D 41 liters.
I tried to create a flag like this:
But it does not work. I have also tried creating 3 measures, like this:
The desired result is the following:
Hi! I finally got it 🙂
The solution was to create two tables more of time with date field each one (dim_tiempo1 and dim_tiempo2). Those tables are not related to nothing.
I have created two filters, one with the date of dim_tiempo1 and another filter with the date of dim_tiempo2.
On the other hand, I changed the formula for literslike this:
Volume (L) =
VAR MinDate = MIN('DIM_TIEMPO1’[FECHA_ID])
VAR MaxDate = MAX('DIM_TIEMPO2’[FECHA_ID])
VAR MaxDatePlus1 = MaxDate + 1
RETURN
SUMX(
FILTER(
FACT_TABLE,
FACT_TABLE[Estado] = "A" && FACT_TABLE[Fecha]= MinDate ||
FACT_TABLE [Estado] IN {"B","C"} && (FACT_TABLE[Fecha]>= MinDate && FACT_TABLE[Fecha]<= MaxDate) ||
FACT_TABLE[Estado] = "D" && FACT_TABLE[Fecha]= MaxDatePlus1
),
FACT_TABLE[Litros]
)
that's all 🙂
Thank you!
@RuthMerchán , Create following measures
M1=
var _max = minx(allselected(table), Table[status] = "A"), Table[Date])
return
calculate(Sum(Table[liters]), Filter( table, Table[Date] =_max && Table[status] = "A"))
M2= calculate(Sum(Table[liters]), Filter( table, Table[status] in {"B", "C"}))
Sum Measure= Max(Values(Table[Status]), [M1] +[M2])
Hi! @amitchandak!
I have tried and finaly when I put the Sum Measure give this error:
Do you have some idea how can I make the measure to obtain the status D?
Thank you very much!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |