Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I have a similar problem to that thread: https://community.powerbi.com/t5/Desktop/Fill-in-blank-values-in-time-series-data-based-on-last-valu...
My data:
When I pivot:
To fill the blanks, I can use this measure (thanks to @ImkeF😞
Last Funnel status = CALCULATE( MAX('Leads Funnel'[FunnelStatusID] ) ,LASTNONBLANK( DATESBETWEEN( 'Dates'[Date],BLANK(),LASTDATE( 'Dates'[Date] ) ) ,CALCULATE(COUNT('Leads Funnel'[FunnelStatusID])) ) )
QUESTION: how can I can get Number of PersonID for each StatusID and each Date, by filling the blank StatusID?
Solved! Go to Solution.
Ok, I found the solution. I needed to add a calculated column EndDate for each Person and Status. Then, I can calculate number of PersonID for each StatusID at each Date. I need to disable relation between Dates table and my Fact Table for it to work.
Number Persons = CALCULATE ( DISTINCTCOUNT ('Persons status'[PersonID]) , FILTER('Persons status', 'Persons status'[Date] <= MAX('Dates wihtout relation'[Date]) && 'Persons status'[EndDate] >= MAX('Dates wihtout relation'[Date])) )
Anybody knows another way to do this with an active relation between Dates table and Fact table?
I know I could cross join tables Persons and Status to simplify the calculation but that would give 2 billions+ rows whereas I have only 2 millions rows right now.
Not exac'tly sure what you're after, as the samples you've showed don't look consistent to me, but please try this measure:
Measure = CALCULATE( COUNT(YourTable[PersonID] ) ;LASTNONBLANK( DATESBETWEEN( 'Dates'[Date];BLANK();LASTDATE( 'Dates'[Date] ) ) ;CALCULATE(COUNT(YourTable[PersonID])) ) )
And don't forget that your Dates-table has to be connected to YourTable.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @ImkeF, thanks for the reply. But your measure doesn't do the trick. Here is the pbix file with the expected result: https://1drv.ms/u/s!AsMpLDRkiLDdqU_QNs1VV-4aMYno
Thnaks for your help!
Sorry, but I don't get your logic here: How can there be 0 in between?
At least my measure is supposed to always return the latest value, even if there are blanks.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
At each date, I want to count number of Persons with their latest status at this date. For example, on 2018-09-07, no PersonID has a row in the source table. For their calculated latest StatusID, we have on September 7:
PersonID 1254 | StatusID 20 (last date with status id 20 is September 2)
PersonID 3325| StatusID 20 (last date with status id 20 is September 6)
PersonID 15487| StatusID 30 (last date with status id 30 is September 4)
The measure I'm looking for would calculate for September 7, 0 Persons with StatusID 10, 2 Persons with StatusID 20 and 1 PersonID with StatusID 30.
More clear?
No, unfortunately not.
Hope someone else picks this up.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Ok, I found the solution. I needed to add a calculated column EndDate for each Person and Status. Then, I can calculate number of PersonID for each StatusID at each Date. I need to disable relation between Dates table and my Fact Table for it to work.
Number Persons = CALCULATE ( DISTINCTCOUNT ('Persons status'[PersonID]) , FILTER('Persons status', 'Persons status'[Date] <= MAX('Dates wihtout relation'[Date]) && 'Persons status'[EndDate] >= MAX('Dates wihtout relation'[Date])) )
Anybody knows another way to do this with an active relation between Dates table and Fact table?
Now this looks like an "Event with duration"-problem. You might find a solution here: https://www.thebiccountant.com/2016/12/01/analyzing-events-with-a-duration-in-dax-further-simplifica...
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Yes, exactly my problem, thanks! I've read the SQLBI article, these guys are awesome
User | Count |
---|---|
139 | |
113 | |
103 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |