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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PBI5851
Helper V
Helper V

Beginning and Ending value

Hello,

I am trying to generate a beginning value and ending value based on the below raw data. 

DateValCountFlag
1/1/2021100Incoming
1/1/2021-20Reject1
1/1/2021-10Reject2
1/1/2021-30Reject3
2/1/2021-5Reject1
2/1/2021-5Reject2
2/1/2021-10Reject3
3/1/202120Incoming
3/1/2021-30Reject1
4/1/202110Incoming

 

I am hoping to get the below structure. 

 JanFebMarApr
Beginnning 402010
Incoming10002010
Reject1-20-5-300
Reject2-10-500
Reject3-30-1000
Ending40201020

 

I thought of using PreviousMonth ,by creating the Ending Measure, but the Previous Month cant be done on a Measure and also without the correct Beginning value for Feb, the Ending is incorrect. Any recommendations of how to resolve this please. 

 

Thank you. 

3 REPLIES 3
PBI5851
Helper V
Helper V

Please could you send me a pbix file using this solution. It doesnt work when i try it out. 

amitchandak
Super User
Super User

@PBI5851 , Create measure with help from date table

 

Beginnning = CALCULATE(sum(Table[Count]),filter(allselected(date),date[date] <=maxx(date,dateadd(date[date]),-1,Month)))
Ending = CALCULATE(sum(Table[Count]),filter(allselected(date),date[date] <=max(date[date])))

Reject1 = calculate(sum(Table[Count]), datesmtd(Date[Date]), filter(Table, Table[Flag] ="Reject1"))
Reject2 = calculate(sum(Table[Count]), datesmtd(Date[Date]), filter(Table, Table[Flag] ="Reject1"))
Reject3 = calculate(sum(Table[Count]), datesmtd(Date[Date]), filter(Table, Table[Flag] ="Reject1"))
Incoming = calculate(sum(Table[Count]), datesmtd(Date[Date]), filter(Table, Table[Flag] ="Incoming"))

 

In matrix use show on row

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-matrix-visual

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak,

Thank you for the solution. However, this will work only if no other value were to be added to the table. Its my mistake of overlooking that scenario and  not providing that information in my question. If the incoming raw data was in this format where there are two more flags but do not account for the Beginning or End, then the "allselected" will not work. .

 

DateValCountFlag
1/1/2021100Incoming
1/1/2021-20Reject1
1/1/2021-10Reject2
1/1/2021-30Reject3
2/1/2021-5Reject1
2/1/2021-5Reject2
2/1/2021-10Reject3
3/1/202120Incoming
3/1/2021-30Reject1
4/1/202110Incoming
1/1/2130Contaminated
2/1/2120user Error
3/1/2110Manufacturing

 

And the matrix should be

excelmatrix.png


How to achieve this ?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors