Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello @all
I have a table with the following data(Table1):
Table 1:
Acc. | Cred | Deb | Date |
A | 1000 | 12/12/2020 | |
B | 20000 | 1/11/2020 | |
B | 20000 | 1/11/2020 | |
C | 550 | 3/10/2020 | |
D | 6000 | 4/10/2020 |
I need to identify the pattern where the "cred" and "deb" are happening at the same date for the same amount(i.e. the amount that is credited is being debited at the same date).
And after identifying it should show me in True() and False().
Please help resolve this query.
Thanks.
Solved! Go to Solution.
Hi @MintuBaruah ,
Sorry for my misunderstanding,please modify the True or False measure :
True or False =
var _cred=CALCULATE( FIRSTNONBLANK('Table1'[Cred],TRUE()),ALLEXCEPT(Table1,Table1[Date]))
var _deb=CALCULATE( FIRSTNONBLANK('Table1'[Deb],TRUE()),ALLEXCEPT(Table1,Table1[Date]))
return IF(_cred=_deb,TRUE(),FALSE())
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MintuBaruah ,
Sorry for my misunderstanding,please modify the True or False measure :
True or False =
var _cred=CALCULATE( FIRSTNONBLANK('Table1'[Cred],TRUE()),ALLEXCEPT(Table1,Table1[Date]))
var _deb=CALCULATE( FIRSTNONBLANK('Table1'[Deb],TRUE()),ALLEXCEPT(Table1,Table1[Date]))
return IF(_cred=_deb,TRUE(),FALSE())
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MintuBaruah ,
According to your description, only set TRUE if Cred and Deb occur on the same day and the amount is the same, and then change the background color to red when it is true, right?
If so , please try:
True or False =
VAR _credDate =
CALCULATE (
FIRSTNONBLANK ( 'Table1'[Date], TRUE () ),
FILTER ( ALLEXCEPT ( Table1, Table1[Acc.] ), 'Table1'[Cred] <> BLANK () )
)
VAR _debDate =
CALCULATE (
LASTNONBLANK ( 'Table1'[Date], TRUE () ),
FILTER ( ALLEXCEPT ( Table1, Table1[Acc.] ), 'Table1'[Deb] <> BLANK () )
)
VAR _credAmount =
CALCULATE ( SUM ( Table1[Cred] ), ALLEXCEPT ( Table1, Table1[Acc.] ) )
VAR _debAmount =
CALCULATE ( SUM ( Table1[Deb] ), ALLEXCEPT ( Table1, Table1[Acc.] ) )
RETURN
IF ( _credDate = _debDate && _credAmount = _debAmount, TRUE (), FALSE () )
Then create a color measure for conditional formatting:
Color = IF([True or False]=TRUE(),"Red")
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-eqin-msft
Thank you for the reply. I tried your solution but it is not working on my side.
Are you taking into consideration that "Acc." should be the same, if so that is not correct as there can be transactions from different "Acc." also.
eg:
Acc. | Cred | Deb | Date |
A | 1000 | 12/12/2020 | |
B | 20000 | 1/11/2020 | |
E | 20000 | 1/11/2020 | |
C | 550 | 3/10/2020 | |
D | 6000 | 4/10/2020 |
Regards,
Mintu Baruah
Hey @MintuBaruah ,
try the following measure. This should show you TRUE when the date has both values and FALSE when it doesn't:
Date With Cred and Deb =
VAR vCred =
CALCULATE(
SUM( 'Table 1'[Cred] ),
ALL( 'Table 1'[Acc.] )
)
VAR vDeb =
CALCULATE(
SUM( 'Table 1'[Deb] ),
ALL( 'Table 1'[Acc.] )
)
RETURN
IF( vCred <> BLANK() && vDeb <> BLANK(),
TRUE(),
FALSE()
)
hi @selimovd
Thank you for the answer.
Can we also highlight the rows after the condition gets True().
for eg. in Red color.
Hey @MintuBaruah ,
yes, that's also possible with conditional formatting.
Create a measure that returns the color for the format. You can also use hex values if you like that more:
Data Color =
IF(
[Date With Cred and Deb] = TRUE(),
"red",
BLANK()
)
This measure you can then use for the formatting:
Conditional table formatting in Power BI Desktop - Power BI | Microsoft Docs
Hello @selimovd
Upon applying the conditional formatting, I noticed that it is identifying data according to "Acc." Header and because of that, it is highlighting rows from different dates too.
I wanted to highlight the data related to the same date.
"I need to identify the pattern where the "cred" and "deb" are happening at the same date for the same amount(i.e. the amount that is credited is being debited at the same date)."
Regards,
Mintu Baruah
Hi @selimovd
Table:
Acc. | Cred | Deb | Date |
A | 1000 | 12/12/2020 | |
B | 20000 | 1/11/2020 | |
B | 20000 | 1/11/2020 | |
C | 550 | 3/10/2020 | |
D | 6000 | 4/10/2020 | |
E | 5000 | 22/9/2020 | |
E | 5000 | 7/9/2020 |
eg: From the table above "E" also has the same transaction pattern as "B", but here condition for E should not be True() as the transactions are taking place on different dates.
And B should be True() as it is taking place on the same date.
Please help resolve this and do let me know if you need further information.
Regards,
Mintu Baruah
Hey @MintuBaruah ,
that's exactly what the measure is doing:
That's the reason I ask you what exactly is not working?
Best regards
Denis
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |