Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear Community,
I stuck on issue how to show previous date data on matrix table.
I made matrix table showing qty each day from plant A and B. I want to make it as showing in second picture with high-lighting the part in yellow. Basically 11/3 is missing so it needs to be added by using the data from 11/2. Also Plant A 11/6 qty should be from 11/5 and plant B 11/2 data to be from 11/1. How can we make it? Thanks for help!
Solved! Go to Solution.
Hi @nbufff ,
You can produce your required output by writing a dax measure like below:
Date_Diff =
VAR StartDate = DATE(2024, 11, 1) -- Starting point
VAR CurrentDate = SELECTEDVALUE(Calendar[Date])
RETURN
IF(
CurrentDate >= StartDate,
CALCULATE(
COUNTROWS('Calendar'),
FILTER(
ALL('Calendar'),
Calendar[Date] >= StartDate &&
Calendar[Date] <= CurrentDate &&
Calendar[IsWorkingDay] = 1
)
),
BLANK() -- If the date is before November 1, return blank
)
The resulting output is shown below. I've transposed the visualization to save space.
I have attached an example pbix file for your reference.
Best regards,
Hi @nbufff ,
You can produce your required output by writing a dax measure like below:
CarryOverQty =
VAR CurrentDate = SELECTEDVALUE(Calendar[Date])
VAR PreviousQty =
CALCULATE(
MAXX(
FILTER(
ALL('Calendar'),
Calendar[Date] < CurrentDate && NOT(ISBLANK([Quantity]))
),
[Quantity]
)
)
RETURN
IF(
ISBLANK([Quantity]),
PreviousQty,
[Quantity]
)
The data model will look like below:
The resulting output will look like as follows:
I have attached an example pbix file for your reference.
Best regards,
@DataNinja777 , I tried your formual in my case. it works on most data but some data seemed weir.
from below screen you can see on 11/21 there's carryover data 52550 which accordig to your method should be 1800 since actually there's no data on that day.
There's few other colum also encountered such issue.
I also show you the table view screen shot for your reference. Pls kindly advise if I can improve.
carryover_mavqty =
VAR currentdate=SELECTEDVALUE(Calendar_Table[Date])
VAR previousqty =
CALCULATE(
MAXX(
FILTER(
ALL(Calendar_Table),
Calendar_Table[Date] < currentdate && NOT(ISBLANK([sum_mavqty]))
),
[sum_mavqty]
)
)
RETURN
IF(
ISBLANK([sum_mavqty]),previousqty,[sum_mavqty])
@DataNinja777 , It works but the situation here little bit complex.
we need to by pass the holdaiy and get the date difference between working days.
e.g. we don't need to show Nov.2 and Nov.3 but we need to show working day difference from Nov.1
thank for advise.
Hi @nbufff ,
You can produce your required output by writing a dax measure like below:
Date_Diff =
VAR StartDate = DATE(2024, 11, 1) -- Starting point
VAR CurrentDate = SELECTEDVALUE(Calendar[Date])
RETURN
IF(
CurrentDate >= StartDate,
CALCULATE(
COUNTROWS('Calendar'),
FILTER(
ALL('Calendar'),
Calendar[Date] >= StartDate &&
Calendar[Date] <= CurrentDate &&
Calendar[IsWorkingDay] = 1
)
),
BLANK() -- If the date is before November 1, return blank
)
The resulting output is shown below. I've transposed the visualization to save space.
I have attached an example pbix file for your reference.
Best regards,
Try
Including Missing Dates =
COALESCE (
[Base Measure],
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
LASTNONBLANKVALUE (
FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] < MaxDate ),
[Base Measure]
)
RETURN
Result
)
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |